from scratch
This commit is contained in:
1 parent
deb9bcea46
commit
402cd48057
24 files changed
+738
-59
No files matched your search
+95
-1
@@ -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)
|
||||
@@ -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 = {},
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
return {
|
||||
"romgrk/barbar.nvim",
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
'nvimdev/dashboard-nvim',
|
||||
event = 'VimEnter',
|
||||
config = function()
|
||||
require('dashboard').setup({
|
||||
-- config
|
||||
})
|
||||
end,
|
||||
dependencies = { { 'nvim-tree/nvim-web-devicons' } },
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
return {
|
||||
{
|
||||
'ThePrimeagen/harpoon',
|
||||
lazy = true,
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
|
||||
config = function()
|
||||
require('lualine').setup()
|
||||
end,
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
return {
|
||||
"iamcco/markdown-preview.nvim",
|
||||
ft = "markdown",
|
||||
build = function()
|
||||
vim.fn["mkdp#util#install"]()
|
||||
end,
|
||||
cmd = {
|
||||
"MarkdownPreviewToggle",
|
||||
"MarkdownPreview",
|
||||
"MarkdownPreviewStop",
|
||||
},
|
||||
}
|
||||
@@ -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
@@ -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,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
return {
|
||||
"kylechui/nvim-surround",
|
||||
|
||||
config = function()
|
||||
require("nvim-surround").setup()
|
||||
end,
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
return {
|
||||
"akinsho/toggleterm.nvim",
|
||||
|
||||
config = function ()
|
||||
require("toggleterm").setup({
|
||||
shade_terminals = false,
|
||||
})
|
||||
end
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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" })
|
||||
Reference in new issue
Block a user