huge updates

This commit is contained in:
sankalp committed 2024-08-19 03:32:26 +05:45
1 parent ca26b00c27
commit 18bd0cb00b
49 files changed
+4210 -2140

No files matched your search

-95
View File
@@ -1,95 +0,0 @@
-- 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 =')
-110
View File
@@ -1,110 +0,0 @@
-- 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 and change without yanking
vim.keymap.set({ 'n', 'x' }, '<A-d>', '"_d', { desc = 'Delete Without Yanking' })
vim.keymap.set({ 'n', 'x' }, '<A-c>', '"_c', { desc = 'Change Without Yanking' })
-- Deleting without yanking empty line
vim.keymap.set('n', 'dd', function()
local is_empty_line = vim.api.nvim_get_current_line():match('^%s*$')
if is_empty_line then
return '"_dd'
else
return 'dd'
end
end, { noremap = true, expr = true, desc = "Don't Yank Empty Line to Clipboard" })
-- Search inside visually highlighted text
vim.keymap.set('x', 'g/', '<esc>/\\%V', { silent = false, desc = 'Search Inside Visual Selection' })
-- Search visually selected text (slightly better than builtins in Neovim>=0.8)
vim.keymap.set('x', '*', [[y/\V<C-R>=escape(@", '/\')<CR><CR>]], { desc = 'Search Selected Text', silent = true })
vim.keymap.set(
'x',
'#',
[[y?\V<C-R>=escape(@", '?\')<CR><CR>]],
{ desc = 'Search Selected Text (Backwards)', silent = true }
)
-- save file
vim.keymap.set('n', '<leader>w', ':w<CR>', { desc = 'Save file' })
-- save and quit
vim.keymap.set('n', '<leader>Q', '<cmd>wq!<CR>', { desc = 'Force save and quit' })
-- Clear highlights on search when pressing <Esc> in normal mode
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- 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', '<A-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
-- for buffers
vim.api.nvim_set_keymap('n', '<Tab>', ':bnext<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<S-Tab>', ':bprev<CR>', { noremap = true, silent = true })
--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', 'vs', ':vsp<CR>', { noremap = true, silent = true })
vim.keymap.set('n', 'hs', ':sp<CR>', { noremap = true, silent = true })
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' })
vim.keymap.set('n', '<Leader>lo', '<cmd>lopen<CR>', { desc = 'Open location list' })
vim.keymap.set('n', '<Leader>lc', '<cmd>lclose<CR>', { desc = 'Close location list' })
vim.keymap.set('n', '<Leader>ln', '<cmd>lnext<CR>', { desc = 'Next location list item' })
vim.keymap.set('n', '<Leader>lp', '<cmd>lprev<CR>', { desc = 'Previous location list item' })
-- 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>')
-95
View File
@@ -1,95 +0,0 @@
-- 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 = 'list' },
},
install = {
missing = true,
colorscheme = { 'moonfly' },
},
checker = {
enabled = true,
notify = false,
},
change_detection = {
enabled = true,
notify = false,
},
ui = {
icons = {
cmd = '',
config = '',
event = '',
ft = '',
init = '',
import = '',
keys = '',
lazy = '󰒲 ',
loaded = '●',
not_loaded = '○',
plugin = '',
runtime = '',
require = '󰢱 ',
source = '',
start = '',
task = '✔ ',
list = {
'●',
'➜',
'★',
'‒',
},
},
},
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
@@ -1,59 +0,0 @@
--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