huge updates

This commit is contained in:
sankalp committed 2024-08-15 19:28:13 +05:45
1 parent d93e388067
commit c9d290595f
37 files changed
+1309 -601

No files matched your search

+95
View File
@@ -0,0 +1,95 @@
-- don't auto comment new line
vim.api.nvim_create_autocmd('BufEnter', { command = [[set formatoptions-=cro]] })
-- to make border as same as neovim ColorScheme
vim.api.nvim_create_autocmd({ 'UIEnter', 'ColorScheme' }, {
callback = function()
local normal = vim.api.nvim_get_hl(0, { name = 'Normal' })
if not normal.bg then
return
end
io.write(string.format('\027Ptmux;\027\027]11;#%06x\007\027\\', normal.bg))
io.write(string.format('\027]11;#%06x\027\\', normal.bg))
end,
})
vim.api.nvim_create_autocmd('UILeave', {
callback = function()
io.write('\027Ptmux;\027\027]111;\007\027\\')
io.write('\027]111\027\\')
end,
})
-- Highlight on yank
vim.api.nvim_create_autocmd('TextYankPost', {
callback = function()
vim.highlight.on_yank()
end,
})
-- go to last loc when opening a buffer
-- this mean that when you open a file, you will be at the last position
vim.api.nvim_create_autocmd('BufReadPost', {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- auto close brackets
vim.api.nvim_create_autocmd('FileType', { pattern = 'man', command = [[nnoremap <buffer><silent> q :quit<CR>]] })
-- show cursor line only in active window
local cursorGrp = vim.api.nvim_create_augroup('CursorLine', { clear = true })
vim.api.nvim_create_autocmd({ 'InsertLeave', 'WinEnter' }, {
pattern = '*',
command = 'set cursorline',
group = cursorGrp,
})
vim.api.nvim_create_autocmd(
{ 'InsertEnter', 'WinLeave' },
{ pattern = '*', command = 'set nocursorline', group = cursorGrp }
)
-- Enable spell checking for certain file types
vim.api.nvim_create_autocmd(
{ 'BufRead', 'BufNewFile' },
-- { pattern = { "*.txt", "*.md", "*.tex" }, command = [[setlocal spell<cr> setlocal spelllang=en,de<cr>]] }
{
pattern = { '*.txt', '*.md', '*.tex' },
callback = function()
vim.opt.spell = true
vim.opt.spelllang = 'en,de'
end,
}
)
-- close some filetypes with <q>
vim.api.nvim_create_autocmd('FileType', {
group = vim.api.nvim_create_augroup('close_with_q', { clear = true }),
pattern = {
'PlenaryTestPopup',
'help',
'lspinfo',
'man',
'notify',
'qf',
'spectre_panel',
'startuptime',
'tsplayground',
'neotest-output',
'checkhealth',
'neotest-summary',
'neotest-output-panel',
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set('n', 'q', '<cmd>close<cr>', { buffer = event.buf, silent = true })
end,
})
-- resize neovim split when terminal is resized
vim.api.nvim_command('autocmd VimResized * wincmd =')
+158
View File
@@ -0,0 +1,158 @@
return {
kind = {
Array = '',
Boolean = '',
Class = '',
Color = '',
Constant = '',
Constructor = '',
Enum = '',
EnumMember = '',
Event = '',
Field = '',
File = '',
Folder = '󰉋',
Function = '',
Interface = '',
Key = '',
Keyword = '',
Method = '',
-- Module = " ",
Module = '',
Namespace = '',
Null = '󰟢',
Number = '',
Object = '',
Operator = '',
Package = '',
Property = '',
Reference = '',
Snippet = '',
String = '',
Struct = '',
Text = '',
TypeParameter = '',
Unit = '',
Value = '',
Variable = '',
},
git = {
LineAdded = '',
LineModified = '',
LineRemoved = '',
FileDeleted = '',
FileIgnored = '◌',
FileRenamed = '',
FileStaged = 'S',
FileUnmerged = '',
FileUnstaged = '',
FileUntracked = 'U',
Diff = '',
Repo = '',
Octoface = '',
Copilot = '',
Branch = '',
},
ui = {
ArrowCircleDown = '',
ArrowCircleLeft = '',
ArrowCircleRight = '',
ArrowCircleUp = '',
BoldArrowDown = '',
BoldArrowLeft = '',
BoldArrowRight = '',
BoldArrowUp = '',
BoldClose = '',
BoldDividerLeft = '',
BoldDividerRight = '',
BoldLineLeft = '▎',
BoldLineMiddle = '┃',
BoldLineDashedMiddle = '┋',
BookMark = '',
BoxChecked = '',
Bug = '',
Stacks = '',
Scopes = '',
Watches = '󰂥',
DebugConsole = '',
Calendar = '',
Check = '',
ChevronRight = '',
ChevronShortDown = '',
ChevronShortLeft = '',
ChevronShortRight = '',
ChevronShortUp = '',
Circle = '',
Close = '󰅖',
CloudDownload = '',
Code = '',
Comment = '',
Dashboard = '',
DividerLeft = '',
DividerRight = '',
DoubleChevronRight = '»',
Ellipsis = '',
EmptyFolder = '',
EmptyFolderOpen = '',
File = '',
FileSymlink = '',
Files = '',
FindFile = '󰈞',
FindText = '󰊄',
Fire = '',
Folder = '󰉋',
FolderOpen = '',
FolderSymlink = '',
Forward = '',
Gear = '',
History = '',
Lightbulb = '',
LineLeft = '▏',
LineMiddle = '│',
List = '',
Lock = '',
NewFile = '',
Note = '',
Package = '',
Pencil = '󰏫',
Plus = '',
Project = '',
Search = '',
SignIn = '',
SignOut = '',
Tab = '󰌒',
Table = '',
Target = '󰀘',
Telescope = '',
Text = '',
Tree = '',
Triangle = '󰐊',
TriangleShortArrowDown = '',
TriangleShortArrowLeft = '',
TriangleShortArrowRight = '',
TriangleShortArrowUp = '',
},
diagnostics = {
BoldError = '',
Error = '',
BoldWarning = '',
Warn = '',
BoldInformation = '',
Info = '',
BoldQuestion = '',
Question = '',
BoldHint = '',
Hint = '󰌶',
Debug = '',
Trace = '✎',
},
misc = {
Robot = '󰚩',
Squirrel = '',
Tag = '',
Watch = '',
Smiley = '',
Package = '',
CircuitBoard = '',
},
}
+84
View File
@@ -0,0 +1,84 @@
local opts = { noremap = true, silent = true }
-- Increment / Decrement
vim.keymap.set('n', '+', '<C-a>')
vim.keymap.set('n', '-', '<C-x>')
-- Select all
vim.keymap.set('n', '<C-a>', 'gg<S-v>G')
-- Replace currently selected text with default register without yanking it
vim.keymap.set('x', '<leader>p', '"_dP')
-- Delete without yanking
vim.keymap.set('n', '<leader>d', '"_d')
vim.keymap.set('v', '<leader>d', '"_d')
-- Clear highlights on search when pressing <Esc> in normal mode
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Resize window using <ctrl> arrow keys
vim.keymap.set('n', '<A-Up>', '<cmd>resize +2<cr>', { desc = 'Increase Window Height' })
vim.keymap.set('n', '<A-Down>', '<cmd>resize -2<cr>', { desc = 'Decrease Window Height' })
vim.keymap.set('n', '<A-Left>', '<cmd>vertical resize -2<cr>', { desc = 'Decrease Window Width' })
vim.keymap.set('n', '<A-Right>', '<cmd>vertical resize +2<cr>', { desc = 'Increase Window Width' })
-- Visual vim.keymap.sets
vim.keymap.set('v', '<leader>r', '"hy:%s/<C-r>h//g<left><left>') -- Replace all instances of highlighted words
vim.keymap.set('v', '<C-s>', ':sort<CR>') -- Sort highlighted text in visual mode with Control+S
vim.keymap.set('v', 'K', ":m '>-2<CR>gv=gv") -- Move current line up
vim.keymap.set('v', 'J', ":m '>+1<CR>gv=gv") -- Move current line down
--utility vim.keymap.setpings
vim.keymap.set('n', 'n', 'nzzzv') -- keep the cursor centered when doing 'n'
vim.keymap.set('n', 'N', 'Nzzzv') -- keep the cursor centered when doing 'N'
vim.keymap.set('n', 'J', 'mzJ`z', { desc = 'Join line without moving the cursor' })
vim.keymap.set('n', 'cn', '*``cgn', { desc = 'Change next match by pressing dot (.)' })
vim.keymap.set('n', 'cN', '*``cgN', { desc = 'Change previous match by pressing dot (.)' })
vim.keymap.set('n', '<leader>vp', '`[v`]<CR>', { desc = 'Select pasted text' })
vim.keymap.set('n', '<C-d>', '<C-d>zz', { desc = 'Scroll down' })
vim.keymap.set('n', '<C-u>', '<C-u>zz', { desc = 'Scroll up' })
vim.keymap.set({ 'n', 'v' }, '<leader>y', '"+y', { desc = 'Copy to system clipboard' })
vim.keymap.set({ 'n', 'v' }, '<leader>p', '"+p', { desc = 'Paste from system clipboard' })
vim.keymap.set({ 'i' }, '<C-l>', '<Right>', { desc = 'Move cursor to right' })
vim.keymap.set({ 'i' }, '<C-h>', '<Left>', { desc = 'Move cursor to right' })
-- Better window management
vim.keymap.set('n', 'hs', ':split<Return>', opts)
vim.keymap.set('n', 'vs', ':vsplit<Return>', opts)
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'Move to left split' })
vim.keymap.set('n', '<C-j>', '<C-w>j', { desc = 'Move to below split' })
vim.keymap.set('n', '<C-k>', '<C-w>k', { desc = 'Move to above split' })
vim.keymap.set('n', '<C-l>', '<C-w>l', { desc = 'Move to right split' })
vim.keymap.set('n', '<A-Up>', '<cmd>resize -2<CR>', { desc = 'Resize split up' })
vim.keymap.set('n', '<A-Down>', '<cmd>resize +2<CR>', { desc = 'Resize split down' })
vim.keymap.set('n', '<A-Left>', '<cmd>vertical resize -2<CR>', { desc = 'Resize split left' })
vim.keymap.set('n', '<A-Right>', '<cmd>vertical resize +2<CR>', { desc = 'Resize split right' })
-- Stay in indent mode
vim.keymap.set('v', '<', '<gv', { desc = '(V) Indent to left' })
vim.keymap.set('v', '>', '>gv', { desc = '(V) Indent to right' })
-- insert semicolon in the end
-- vim.keymap.set('i', '<A-;>', '<Esc>miA;<Esc>`ii', { desc = 'insert semicolon in the end' })
-- Change text without putting it into the vim register,
vim.keymap.set({ 'n', 'x' }, 'c', '"_c', { desc = 'Change without yanking' })
vim.keymap.set({ 'n', 'x' }, 'C', '"_C', { desc = 'Change without yanking' })
vim.keymap.set({ 'n', 'x' }, 'cc', '"_cc', { desc = 'Change without yanking' })
vim.keymap.set({ 'n', 'x' }, 'x', '"_x', { desc = 'delete without yanking' })
-- Better escape using jk in insert and terminal mode
vim.keymap.set('i', 'jk', '<ESC>')
vim.keymap.set('i', 'kj', '<ESC>')
vim.keymap.set('i', 'jj', '<ESC>')
-- Terminal Mappings
vim.keymap.set('t', 'jk', '<C-\\><C-n>')
vim.keymap.set('t', 'kj', '<C-\\><C-n>')
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>')
-- save file
vim.keymap.set({ 'i', 'v', 'n', 's' }, '<A-s>', '<cmd>wa<cr><esc>', { desc = 'Save all file' })
+77
View File
@@ -0,0 +1,77 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
---@diagnostic disable-next-line: undefined-field
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system({ 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
{ out, 'WarningMsg' },
{ '\nPress any key to exit...' },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
spec = {
{ import = 'plugins' },
-- { import = 'plugins.themes' },
},
install = {
missing = true,
colorscheme = { 'onedark' },
},
checker = {
enabled = true,
notify = false,
},
change_detection = {
enabled = true,
notify = false,
},
ui = {
icons = {
ft = '',
lazy = '󰂠 ',
loaded = '',
not_loaded = '',
},
},
performance = {
rtp = {
disabled_plugins = {
'2html_plugin',
'tohtml',
'getscript',
'getscriptPlugin',
'gzip',
'logipat',
'netrw',
'netrwPlugin',
'netrwSettings',
'netrwFileHandlers',
'matchit',
'tar',
'tarPlugin',
'rrhelper',
'spellfile_plugin',
'vimball',
'vimballPlugin',
'zip',
'zipPlugin',
'tutor',
'rplugin',
'syntax',
'synmenu',
'optwin',
'compiler',
'bugreport',
'ftplugin',
},
},
},
})
+59
View File
@@ -0,0 +1,59 @@
--Remap space as leader key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.opt.backup = false -- creates a backup file
vim.opt.clipboard = 'unnamedplus' -- allows neovim to access the system clipboard
vim.opt.cmdheight = 0 -- more space in the neovim command line for displaying messages
vim.opt.completeopt = { 'menuone', 'noselect' } -- mostly just for cmp
vim.opt.conceallevel = 0 -- so that `` is visible in markdown files
-- vim.opt.fileencoding = "utf-8" -- the encoding written to a file
vim.opt.hlsearch = true -- highlight all matches on previous search pattern
vim.opt.ignorecase = true -- ignore case in search patterns
vim.opt.mouse = 'a' -- allow the mouse to be used in neovim
vim.opt.pumheight = 10 -- pop up menu height
vim.opt.pumblend = 10
vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
vim.opt.showtabline = 2 -- always show tabs
vim.opt.smartcase = true -- smart case
vim.opt.smartindent = true -- make indenting smarter again
vim.opt.splitbelow = true -- force all horizontal splits to go below current window
vim.opt.splitright = true -- force all vertical splits to go to the right of current window
vim.opt.swapfile = false -- creates a swapfile
vim.opt.termguicolors = true -- set term gui colors (most terminals support this)
vim.opt.timeoutlen = 1000 -- time to wait for a mapped sequence to complete (in milliseconds)
vim.opt.undofile = true -- enable persistent undo
vim.opt.updatetime = 100 -- faster completion (4000ms default)
vim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
vim.opt.expandtab = true -- convert tabs to spaces
vim.opt.shiftwidth = 2 -- the number of spaces inserted for each indentation
vim.opt.tabstop = 2 -- insert 2 spaces for a tab
vim.opt.cursorline = false -- highlight the current line
vim.opt.cursorlineopt = 'number'
vim.opt.number = true -- set numbered lines
vim.opt.laststatus = 0 --disable native statusline
vim.opt.showcmd = false
vim.opt.ruler = false
vim.opt.relativenumber = true -- set relative numbered lines
vim.opt.numberwidth = 4 -- set number column width to 2 {default 4}
vim.opt.signcolumn = 'yes' -- always show the sign column, otherwise it would shift the text each time
vim.opt.wrap = false -- display lines as one long line
vim.opt.scrolloff = 0
vim.opt.sidescrolloff = 8
vim.opt.guifont = 'monospace:h17' -- the font used in graphical neovim applications
vim.opt.title = true
vim.opt.titlelen = 0 -- do not shorten title
vim.opt.inccommand = 'split' -- split below for to show replaces
vim.opt.virtualedit = 'block'
vim.opt.fillchars = vim.opt.fillchars + 'eob: '
vim.opt.fillchars:append({
stl = ' ',
})
vim.opt.shortmess:append('c')
vim.cmd('set whichwrap+=<,>,[,],h,l')
vim.cmd([[set iskeyword+=-]])
vim.g.netrw_banner = 0
vim.g.netrw_mouse = 2
+283
View File
@@ -0,0 +1,283 @@
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',
},
'<C-s>',
'<cmd>w<cr><esc>',
{
desc = 'Save file',
}
)
map('i', '<C-v>', '<ESC>"+p<ESC>a', {
desc = 'Paste from clipboard',
})
map('n', '<A-v>', 'm`o<ESC>p``', {
desc = 'Paste below',
})
map('n', '<A-p>', 'm`O<ESC>p``', {
desc = 'Paste above',
})
map(
{
'n',
'x',
},
'<C-c>',
'"+y<ESC>',
{
desc = 'Copy to clipboard',
}
)
map(
{
'n',
'x',
},
'<C-x>',
'"+y<ESC>dd',
{
desc = 'Cut to clipboard',
}
)
-- Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
map('n', '<A-r>', "printf('`[%s`]', getregtype()[0])", {
expr = true,
desc = 'reselect last pasted area',
})
map(
{
'i',
'v',
'n',
's',
},
'<C-q>',
'<cmd>wq!<cr><esc>',
{
desc = 'Force Save file and quit',
}
)
-- Select all text in the current buffer
map('n', '<C-a>', ':keepjumps normal! ggyG<cr>', {
desc = 'Select all',
})
-- quit
map('n', '<A-q>', '<cmd>wqa!<cr>', {
desc = 'Quit all',
})
-- go to beginning and end in insert mode
map('i', '<A-b>', '<ESC>^i', {
desc = 'Go to beginning of line',
})
map('i', '<A-e>', '<End>', {
desc = 'Go to end of line',
})
-- Go to the beginning and end of current line in insert mode quickly
map('i', '<A-h>', '<HOME>')
map('i', '<A-l>', '<END>')
-- insert semicolon in the end
map('i', '<A-;>', '<Esc>miA;<Esc>`ii', {
desc = 'insert semicolon in the end',
})
-- Turn the word under cursor to upper case
map('i', '<c-u>', '<Esc>viwUea')
-- Turn the current word into lower case
map('i', '<c-t>', '<Esc>b~lea')
-- Undo
map('i', '<A-z>', '<C-O>u')
-- navigate within insert mode
map('i', '<C-h>', '<Left>', {
desc = 'Move Left',
})
map('i', '<C-l>', '<Right>', {
desc = 'Move Right',
})
map('i', '<C-j>', '<Down>', {
desc = 'Move Down',
})
map('i', '<C-k>', '<Up>', {
desc = 'Move Up',
})
-- Copy whole buffer
map('n', '<C-y>', '<cmd>%y+<CR>', {
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', '<ESC>')
map('i', 'kj', '<ESC>')
map('i', 'jj', '<ESC>')
-- Terminal Mappings
map('t', 'jk', '<C-\\><C-n>')
map('t', 'kj', '<C-\\><C-n>')
map('t', '<ESC>', '<C-\\><C-n>')
-- Move with shift-arrows
map('n', '<S-Left>', '<C-w><S-h>', {
desc = 'Move window to the left',
})
map('n', '<S-Down>', '<C-w><S-j>', {
desc = 'Move window down',
})
map('n', '<S-Up>', '<C-w><S-k>', {
desc = 'Move window up',
})
map('n', '<S-Right>', '<C-w><S-l>', {
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', '<C-d>', '<C-d>zz')
map('n', '<C-u>', '<C-u>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', '?', '?<c-g>u')
map('i', '!', '!<c-g>u')
map('i', ',', ',<c-g>u')
map('i', '.', '.<c-g>u')
map('i', ';', ';<c-g>u')
-- compromised backward search when comma is being used as localleader
map('n', '<A-,>', ',')
-- Better up/down
map({ 'n', 'x' }, 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map({ 'n', 'x' }, '<Down>', "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' }, '<Up>', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- Move text up and down
map('n', '<A-j>', '<cmd>m .+1<cr>==', { desc = 'Move Down' })
map('n', '<A-k>', '<cmd>m .-2<cr>==', { desc = 'Move Up' })
map('i', '<A-j>', '<esc><cmd>m .+1<cr>==gi', { desc = 'Move Down' })
map('i', '<A-k>', '<esc><cmd>m .-2<cr>==gi', { desc = 'Move Up' })
map('v', '<A-j>', ":m '>+1<cr>gv=gv", { desc = 'Move Down' })
map('v', '<A-k>', ":m '<-4<cr>gv=gv", { desc = 'Move Up' })