from scratch

This commit is contained in:
sankalp committed 2024-08-13 02:36:10 +05:45
1 parent deb9bcea46
commit 402cd48057
24 files changed
+738 -59

No files matched your search

+1 -2
View File
@@ -1,7 +1,6 @@
vim.cmd("let mapleader = ' '")
require('preferences')
require('keymaps')
require('remaps')
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
+15 -1
View File
@@ -1,19 +1,33 @@
{
"LuaSnip": { "branch": "master", "commit": "b84eeb3641b08324287587b426ec974b888390d9" },
"barbar.nvim": { "branch": "master", "commit": "53b5a2f34b68875898f0531032fbf090e3952ad7" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"codeium.vim": { "branch": "main", "commit": "0b74f274b82c00eaad4b5b5cd8b2e76f872d19f1" },
"dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" },
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" },
"none-ls.nvim": { "branch": "main", "commit": "cfa65d86e21eeb60544d5e823f6db43941322a53" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim": { "branch": "main", "commit": "18bab5ec4c782cdf7d7525dbe89c60bfa02fc195" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "e5a05ba5e298cc1e1dad8eb8095b8d4d89a7f793" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" },
"onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"ultimate-autopair.nvim": { "branch": "v0.6", "commit": "1420fb9e07b1d80cc6d87e7d90827fb2c1109cb3" }
"toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" },
"ultimate-autopair.nvim": { "branch": "v0.6", "commit": "1420fb9e07b1d80cc6d87e7d90827fb2c1109cb3" },
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" }
}
+95 -1
View File
@@ -1,10 +1,104 @@
vim.keymap.set('n', '<C-n>', ':Neotree filesystem reveal left toggle<CR>')
-- File Explorer
vim.keymap.set('n', '<leader>n', ':Neotree filesystem reveal left toggle<CR>')
-- Telescope
vim.keymap.set('n', '<leader>ff', ':Telescope find_files<CR>')
vim.keymap.set('n', '<leader>tc', ':Telescope colorscheme<CR>')
vim.keymap.set('n', '<leader>of', ':Telescope oldfiles<CR>')
vim.keymap.set('n', '<leader>tl', ':Telescope live_grep<CR>')
vim.keymap.set('n', '<leader>km', ':Telescope keymaps<CR>')
vim.keymap.set('n', '<leader>tf', function()
require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown({
previewer = false,
}))
end)
-- formatter
vim.keymap.set('n', '<leader>ft', vim.lsp.buf.format, {})
-- buffer
vim.keymap.set('n', '<tab>', ':BufferNext<CR>')
vim.keymap.set('n', '<S-tab>', ':BufferPrevious<CR>')
vim.keymap.set('n', '<leader>q', ':BufferClose<CR>')
-- comment
vim.keymap.set('n', '<leader>/', 'gcc', { remap = true })
-- terminal
vim.keymap.set('n', '<leader>tr', ':ToggleTerm<CR>')
-- File Explorer
vim.keymap.set('n', '<leader>e', function()
require('oil').toggle_float()
end)
-- Clear search, diff update and redraw
vim.keymap.set({ 'i', 'n' }, '<esc>', '<cmd>noh<cr><esc>', { desc = 'Escape and clear hlsearch' })
-- Move to window using the <ctrl> hjkl keys
vim.keymap.set('n', '<C-h>', '<C-w>h', { desc = 'Go to Left Window', remap = true })
vim.keymap.set('n', '<C-j>', '<C-w>j', { desc = 'Go to Lower Window', remap = true })
vim.keymap.set('n', '<C-k>', '<C-w>k', { desc = 'Go to Upper Window', remap = true })
vim.keymap.set('n', '<C-l>', '<C-w>l', { desc = 'Go to Right Window', remap = true })
-- Move with shift-arrows
vim.keymap.set('n', '<S-Left>', '<C-w><S-h>', {
desc = 'Move window to the left',
})
vim.keymap.set('n', '<S-Down>', '<C-w><S-j>', {
desc = 'Move window down',
})
vim.keymap.set('n', '<S-Up>', '<C-w><S-k>', {
desc = 'Move window up',
})
vim.keymap.set('n', '<S-Right>', '<C-w><S-l>', {
desc = 'Move window to the right',
})
-- Resize window using <ctrl> arrow keys
vim.keymap.set('n', '<C-Up>', '<cmd>resize +2<cr>', { desc = 'Increase Window Height' })
vim.keymap.set('n', '<C-Down>', '<cmd>resize -2<cr>', { desc = 'Decrease Window Height' })
vim.keymap.set('n', '<C-Left>', '<cmd>vertical resize -2<cr>', { desc = 'Decrease Window Width' })
vim.keymap.set('n', '<C-Right>', '<cmd>vertical resize +2<cr>', { desc = 'Increase Window Width' })
-- clear notification
vim.keymap.set('n', '<leader>mu', function()
require('notify').dismiss({ silent = true, pending = true })
end, { desc = 'Dismiss All Notifications' })
-- Harpoon Keybinds
-- Open harpoon ui
vim.keymap.set('n', '<leader>ho', function()
harpoon_ui.toggle_quick_menu()
end)
-- Add current file to harpoon
vim.keymap.set('n', '<leader>ha', function()
harpoon.mark.add_file()
end)
-- Remove current file from harpoon
vim.keymap.set('n', '<leader>hr', function()
harpoon.mark.rm_file()
end)
-- Quickly jump to harpooned files
vim.keymap.set('n', '<leader>1', function()
harpoon.ui.nav_file(1)
end)
vim.keymap.set('n', '<leader>2', function()
harpoon.ui.nav_file(2)
end)
vim.keymap.set('n', '<leader>3', function()
harpoon.ui.nav_file(3)
end)
vim.keymap.set('n', '<leader>4', function()
harpoon.ui.nav_file(4)
end)
vim.keymap.set('n', '<leader>5', function()
harpoon.ui.nav_file(5)
end)
+4 -6
View File
@@ -1,8 +1,6 @@
return {
'altermo/ultimate-autopair.nvim',
event = { 'InsertEnter', 'CmdlineEnter' },
branch = 'v0.6', --recommended as each new version will have breaking changes
opts = {
--Config goes here
},
'altermo/ultimate-autopair.nvim',
event = { 'InsertEnter', 'CmdlineEnter' },
branch = 'v0.6',
opts = {},
}
+3
View File
@@ -0,0 +1,3 @@
return {
"romgrk/barbar.nvim",
}
+25
View File
@@ -0,0 +1,25 @@
return {
'Exafunction/codeium.vim',
event = 'BufEnter',
cmd = 'Codeium',
build = 'Codeium Auth:',
dependencies = {
'nvim-lua/plenary.nvim',
'hrsh7th/nvim-cmp',
},
config = function()
vim.keymap.set('i', '<C-g>', function()
return vim.fn['codeium#Accept']()
end, { expr = true, silent = true })
vim.keymap.set('i', '<c-;>', function()
return vim.fn['codeium#CycleCompletions'](1)
end, { expr = true, silent = true })
vim.keymap.set('i', '<c-,>', function()
return vim.fn['codeium#CycleCompletions'](-1)
end, { expr = true, silent = true })
vim.keymap.set('i', '<c-x>', function()
return vim.fn['codeium#Clear']()
end, { expr = true, silent = true })
end,
}
+22 -22
View File
@@ -1,27 +1,27 @@
return {
'navarasu/onedark.nvim',
'navarasu/onedark.nvim',
config = function()
require('onedark').setup({
style = 'deep',
transparent = true,
term_colors = false,
ending_tildes = false,
cmp_itemkind_reverse = false,
-- toggle_style_key = '<leader>ot',
-- toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' },
config = function()
require('onedark').setup({
style = 'deep',
transparent = true,
term_colors = false,
ending_tildes = false,
cmp_itemkind_reverse = false,
-- toggle_style_key = '<leader>ot',
-- toggle_style_list = { 'dark', 'darker', 'cool', 'warm', 'warmer', 'deep', 'light' },
-- Options are italic, bold, underline, none and combos 'italic,bold'
code_style = {
comments = 'italic',
keywords = 'none',
functions = 'none',
strings = 'none',
variables = 'none',
},
-- Options are italic, bold, underline, none and combos 'italic,bold'
code_style = {
comments = 'italic',
keywords = 'none',
functions = 'none',
strings = 'none',
variables = 'none',
},
lualine = { transparent = true },
diagnostics = { darker = true, undercurl = true, background = false },
})
end,
lualine = { transparent = true },
diagnostics = { darker = true, undercurl = true, background = false },
})
end,
}
+3 -2
View File
@@ -37,16 +37,17 @@ return {
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' }, -- For luasnip users.
{ name = 'codeium' },
}, {
{ name = 'buffer' },
}),
formatting = {
format = lspkind.cmp_format({
mode = 'symbol', -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
-- The function below will be called before any actual modifications from lspkind
+10
View File
@@ -0,0 +1,10 @@
return {
'nvimdev/dashboard-nvim',
event = 'VimEnter',
config = function()
require('dashboard').setup({
-- config
})
end,
dependencies = { { 'nvim-tree/nvim-web-devicons' } },
}
+6
View File
@@ -0,0 +1,6 @@
return {
{
'ThePrimeagen/harpoon',
lazy = true,
},
}
+17
View File
@@ -23,6 +23,23 @@ return {
},
},
capabilities = capabilities,
handlers = handlers,
})
lspconfig.clangd.setup({
capabilities = capabilities,
handlers = handlers,
})
lspconfig.gdscript.setup({
capabilities = capabilities,
})
lspconfig.pyright.setup({
capabilities = capabilities,
handlers = handlers,
})
lspconfig.biome.setup({
capabilities = capabilities,
handlers = handlers,
})
end,
},
+7
View File
@@ -0,0 +1,7 @@
return {
'nvim-lualine/lualine.nvim',
config = function()
require('lualine').setup()
end,
}
+12
View File
@@ -0,0 +1,12 @@
return {
"iamcco/markdown-preview.nvim",
ft = "markdown",
build = function()
vim.fn["mkdp#util#install"]()
end,
cmd = {
"MarkdownPreviewToggle",
"MarkdownPreview",
"MarkdownPreviewStop",
},
}
+7 -7
View File
@@ -1,9 +1,9 @@
return {
'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
},
}
+15 -9
View File
@@ -1,13 +1,19 @@
return {
'nvimtools/none-ls.nvim',
'nvimtools/none-ls.nvim',
config = function()
local null_ls = require('null-ls')
config = function()
local null_ls = require('null-ls')
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
},
})
end,
null_ls.setup({
sources = {
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.prettier,
null_ls.builtins.formatting.clang_format,
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.gdformat,
null_ls.builtins.formatting.djhtml,
null_ls.builtins.formatting.biome,
},
})
end,
}
+26
View File
@@ -0,0 +1,26 @@
return {
'rcarriga/nvim-notify',
config = function()
vim.notify = require('notify')
require('notify')('Welcome Back!')
require('notify').setup({
background_colour = 'Normal',
fps = 30,
icons = {
DEBUG = '',
ERROR = '',
INFO = '',
TRACE = '✎',
WARN = '',
},
level = 2,
minimum_width = 40,
maximum_width = 40,
render = 'wrapped-compact',
stages = 'slide',
timeout = 2000,
})
end,
}
+7
View File
@@ -0,0 +1,7 @@
return {
"kylechui/nvim-surround",
config = function()
require("nvim-surround").setup()
end,
}
+15
View File
@@ -0,0 +1,15 @@
return {
"nvim-treesitter/nvim-treesitter",
build = ":TSUpdate",
config = function()
local configs = require("nvim-treesitter.configs")
configs.setup({
ensure_installed = { "c", "lua", "vim", "vimdoc", "python", "cpp", "html", "css", "javascript", "typescript", "json", "php" },
sync_install = false,
highlight = { enable = true },
indent = { enable = true },
})
end,
}
+40
View File
@@ -0,0 +1,40 @@
vim.api.nvim_create_autocmd('FileType', {
pattern = 'oil',
callback = function()
vim.opt_local.colorcolumn = ''
end,
})
return {
{
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { 'nvim-tree/nvim-web-devicons' },
config = function()
require('oil').setup({
use_default_keymaps = false,
keymaps = {
['g?'] = 'actions.show_help',
['<CR>'] = 'actions.select',
['<C-\\>'] = 'actions.select_split',
['<C-enter>'] = 'actions.select_vsplit', -- this is used to navigate left
['<C-t>'] = 'actions.select_tab',
['<C-p>'] = 'actions.preview',
['<C-c>'] = 'actions.close',
['<C-r>'] = 'actions.refresh',
['-'] = 'actions.parent',
['_'] = 'actions.open_cwd',
['`'] = 'actions.cd',
['~'] = 'actions.tcd',
['gs'] = 'actions.change_sort',
['gx'] = 'actions.open_external',
['g.'] = 'actions.toggle_hidden',
},
view_options = {
show_hidden = false,
},
})
end,
},
}
+19 -2
View File
@@ -1,13 +1,30 @@
return {
'nvim-telescope/telescope.nvim',
tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' },
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-fzf-native.nvim',
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build',
cond = vim.fn.executable('cmake') == 1,
},
config = function()
require('telescope').setup({
pickers = {
colorscheme = { enable_preview = true },
colorscheme = {
enable_preview = true,
},
},
defaults = {
layout_config = {
horizontal = {
preview_cutoff = 0,
},
},
},
})
-- Enable telescope fzf native, if installed
pcall(require('telescope').load_extension, 'fzf')
end,
}
+9
View File
@@ -0,0 +1,9 @@
return {
"akinsho/toggleterm.nvim",
config = function ()
require("toggleterm").setup({
shade_terminals = false,
})
end
}
+42
View File
@@ -0,0 +1,42 @@
return {
{
'gelguy/wilder.nvim',
keys = {
':',
'/',
'?',
},
dependencies = {
'catppuccin/nvim',
},
config = function()
local wilder = require('wilder')
-- Enable wilder when pressing :, / or ?
wilder.setup({ modes = { ':', '/', '?' } })
-- Enable fuzzy matching for commands and buffers
wilder.set_option('pipeline', {
wilder.branch(
wilder.cmdline_pipeline({
fuzzy = 1,
}),
wilder.vim_search_pipeline({
fuzzy = 1,
})
),
})
wilder.set_option(
'renderer',
wilder.popupmenu_renderer(wilder.popupmenu_palette_theme({
border = 'rounded',
max_height = '75%',
min_height = 0,
prompt_position = 'top',
reverse = 0,
}))
)
end,
},
}
+60 -7
View File
@@ -1,8 +1,61 @@
vim.cmd([[autocmd FileType * set formatoptions-=ro]])
-- This file is automatically loaded by plugins.core
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
vim.cmd('set number')
vim.cmd('set relativenumber')
vim.cmd('set noexpandtab')
vim.cmd('set tabstop=6')
vim.cmd('set shiftwidth=6')
vim.cmd('set nowrap')
local opt = vim.opt
opt.number = true
opt.relativenumber = true
opt.expandtab = false
opt.tabstop = 6
opt.shiftwidth = 6
opt.wrap = false
-- netrw file explorer settings
vim.g.netrw_winsize = 20
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 1
opt.cursorline = true -- Enable highlighting of the current line
opt.expandtab = true -- Use spaces instead of tabs
opt.breakindent = true
opt.clipboard = 'unnamedplus' -- allows neovim to access the system clipboard
opt.cmdheight = 1 -- more space in the neovim command line for displaying messages
opt.conceallevel = 0 -- so that `` is visible in markdown files
opt.hlsearch = true -- highlight all matches on previous search pattern
opt.ignorecase = true -- ignore case in search patterns
opt.inccommand = 'split' -- preview incremental substitute
opt.mouse = 'a' -- allow the mouse to be used in neovim
opt.numberwidth = 4 -- set number column width to 2 {default 4}
opt.scrolloff = 10
opt.shiftround = true -- round indent
opt.shiftwidth = 4 -- the number of spaces inserted for each indentation
opt.showcmd = false
opt.showmode = false -- we don't need to see things like -- INSERT -- anymore
opt.showtabline = 0 -- always show tabs
opt.signcolumn = 'yes' -- always show the sign column, otherwise it would shift the text each timeout
opt.smartcase = true -- smart case
opt.smartindent = true -- make indenting smarter again
opt.smarttab = true
opt.splitbelow = true -- force all horizontal splits to go below current window
opt.splitright = true -- force all vertical splits to go right of the current window
opt.swapfile = false -- creastes a swapfile
opt.tabstop = 4 -- insert 2 spaces for a tab
opt.undofile = true -- enable persistent undofile
opt.undolevels = 10000
opt.updatetime = 50 -- faster completion (4000ms default)
opt.writebackup = false -- donot edit backups
opt.backup = false -- creates a backup file
opt.autowrite = true
opt.autoindent = true
opt.ai = true
-- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0
vim.opt.path:append({ '**' })
vim.opt.shortmess:append({ W = true, I = true, c = true })
-- hides `~` at the end of buffer
vim.cmd([[set fillchars+=eob:\ ]])
vim.cmd([[autocmd FileType * set formatoptions-=ro]])
+278
View File
@@ -0,0 +1,278 @@
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" })