feat(nvim): cleanup, fixes and helpers

This commit is contained in:
2024-09-30 21:41:35 +03:00
parent 120345b562
commit 9c8644de17
9 changed files with 689 additions and 270 deletions

View File

@@ -1,4 +1,4 @@
column_width = 120 column_width = 80
line_endings = "Unix" line_endings = "Unix"
indent_type = "Spaces" indent_type = "Spaces"
indent_width = 2 indent_width = 2

View File

@@ -7,7 +7,14 @@
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git' local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } local out = vim.fn.system {
'git',
'clone',
'--filter=blob:none',
'--branch=stable',
lazyrepo,
lazypath,
}
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({ vim.api.nvim_echo({
{ 'Failed to clone lazy.nvim:\n', 'ErrorMsg' }, { 'Failed to clone lazy.nvim:\n', 'ErrorMsg' },
@@ -21,7 +28,10 @@ end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
-- ── Add ~/.local/bin to the PATH ──────────────────────────────────── -- ── Add ~/.local/bin to the PATH ────────────────────────────────────
vim.fn.setenv('PATH', vim.fn.expand '$HOME/.local/bin' .. ':' .. vim.fn.expand '$PATH') vim.fn.setenv(
'PATH',
vim.fn.expand '$HOME/.local/bin' .. ':' .. vim.fn.expand '$PATH'
)
require 'options' require 'options'
require 'autogroups' require 'autogroups'

View File

@@ -7,24 +7,48 @@ local autocmd = vim.api.nvim_create_autocmd -- Create autocommand
-- ── Highlight on yank ─────────────────────────────────────────────── -- ── Highlight on yank ───────────────────────────────────────────────
-- See `:help vim.highlight.on_yank()` -- See `:help vim.highlight.on_yank()`
local highlight_group = augroup('YankHighlight', { clear = true })
autocmd('TextYankPost', { autocmd('TextYankPost', {
callback = function() vim.highlight.on_yank() end, callback = function() vim.highlight.on_yank() end,
group = highlight_group, group = augroup('YankHighlight', { clear = true }),
pattern = '*', pattern = '*',
}) })
-- ── Windows to close with "q" ─────────────────────────────────────── -- ── Windows to close with "q" ───────────────────────────────────────
autocmd('FileType', { autocmd('FileType', {
callback = function() vim.keymap.set('n', '<esc>', ':bd<CR>', { buffer = true, silent = true }) end, group = augroup('close_with_q', { clear = true }),
pattern = { pattern = {
'PlenaryTestPopup',
'checkhealth',
'dbout',
'gitsigns.blame',
'grug-far',
'help', 'help',
'startuptime',
'qf',
'lspinfo', 'lspinfo',
'man', 'man',
'checkhealth', 'neotest-output',
'neotest-output-panel',
'neotest-summary',
'notify',
'qf',
'spectre_panel',
'startuptime',
'tsplayground',
}, },
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set('n', 'q', '<cmd>close<cr>', {
buffer = event.buf,
silent = true,
desc = 'Quit buffer',
})
end,
})
-- ── make it easier to close man-files when opened inline ────────────
autocmd('FileType', {
group = augroup('man_unlisted', { clear = true }),
pattern = { 'man' },
callback = function(event) vim.bo[event.buf].buflisted = false end,
}) })
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

View File

@@ -32,7 +32,10 @@ vim.opt.showmode = false
-- Sync clipboard between OS and Neovim. -- Sync clipboard between OS and Neovim.
-- Schedule the setting after `UiEnter` because it can increase startup-time. -- Schedule the setting after `UiEnter` because it can increase startup-time.
-- See `:help 'clipboard'` -- See `:help 'clipboard'`
vim.schedule(function() vim.opt.clipboard = 'unnamedplus' end) vim.schedule(function()
local c = vim.env.SSH_TTY and '' or 'unnamedplus'
vim.opt.clipboard = c
end)
vim.opt.breakindent = true -- Enable break indent vim.opt.breakindent = true -- Enable break indent
vim.opt.smartindent = true -- Insert indents automatically vim.opt.smartindent = true -- Insert indents automatically
@@ -92,7 +95,8 @@ vim.g.loaded_ruby_provider = 0
-- kevinhwang91/nvim-ufo settings -- kevinhwang91/nvim-ufo settings
vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]] vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]
vim.o.foldcolumn = '1' -- '0' is not bad vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevel = 99
vim.o.foldlevelstart = 99 vim.o.foldlevelstart = 99
vim.o.foldenable = true vim.o.foldenable = true
@@ -111,7 +115,17 @@ vim.g.noice_ignored_filetypes = {
-- ── Deal with word wrap ─────────────────────────────────────────────────────── -- ── Deal with word wrap ───────────────────────────────────────────────────────
local m = vim.api.nvim_set_keymap local m = vim.api.nvim_set_keymap
m('n', 'k', "v:count == 0 ? 'gk' : 'k'", { desc = 'Move up', noremap = true, expr = true }) m(
m('n', 'j', "v:count == 0 ? 'gj' : 'j'", { desc = 'Move down', noremap = true, expr = true }) 'n',
'k',
"v:count == 0 ? 'gk' : 'k'",
{ desc = 'Move up', noremap = true, expr = true }
)
m(
'n',
'j',
"v:count == 0 ? 'gj' : 'j'",
{ desc = 'Move down', noremap = true, expr = true }
)
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et

View File

@@ -4,9 +4,11 @@ return {
{ {
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
lazy = false, lazy = false,
version = false, -- Use the latest version of the plugin
event = 'InsertEnter', event = 'InsertEnter',
dependencies = { dependencies = {
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-nvim-lsp',
-- ── LuaSnip Dependencies ──────────────────────────────────────────── -- ── LuaSnip Dependencies ────────────────────────────────────────────
-- Snippet Engine for Neovim written in Lua. -- Snippet Engine for Neovim written in Lua.
-- https://github.com/L3MON4D3/LuaSnip -- https://github.com/L3MON4D3/LuaSnip
@@ -14,6 +16,7 @@ return {
-- luasnip completion source for nvim-cmp -- luasnip completion source for nvim-cmp
-- https://github.com/saadparwaiz1/cmp_luasnip -- https://github.com/saadparwaiz1/cmp_luasnip
{ 'saadparwaiz1/cmp_luasnip' }, { 'saadparwaiz1/cmp_luasnip' },
-- ── Adds other completion capabilities. ───────────────────────────── -- ── Adds other completion capabilities. ─────────────────────────────
-- ── nvim-cmp does not ship with all sources by default. -- ── nvim-cmp does not ship with all sources by default.
-- ── They are split into multiple repos for maintenance purposes. -- ── They are split into multiple repos for maintenance purposes.
@@ -23,6 +26,7 @@ return {
-- cmp import and use all environment variables from .env.* and system -- cmp import and use all environment variables from .env.* and system
-- https://github.com/SergioRibera/cmp-dotenv -- https://github.com/SergioRibera/cmp-dotenv
{ 'SergioRibera/cmp-dotenv' }, { 'SergioRibera/cmp-dotenv' },
-- ── Other deps ────────────────────────────────────────────────────── -- ── Other deps ──────────────────────────────────────────────────────
-- vscode-like pictograms for neovim lsp completion items -- vscode-like pictograms for neovim lsp completion items
-- https://github.com/onsails/lspkind.nvim -- https://github.com/onsails/lspkind.nvim
@@ -62,9 +66,15 @@ return {
require('copilot_cmp').setup() require('copilot_cmp').setup()
local has_words_before = function() local has_words_before = function()
if vim.api.nvim_get_option_value('buftype', {}) == 'prompt' then return false end if vim.api.nvim_get_option_value('buftype', {}) == 'prompt' then
return false
end
local line, col = table.unpack(vim.api.nvim_win_get_cursor(0)) local line, col = table.unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match '^%s*$' == nil return col ~= 0
and vim.api
.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]
:match '^%s*$'
== nil
end end
cmp.setup { cmp.setup {
@@ -75,6 +85,8 @@ return {
show_labelDetails = true, show_labelDetails = true,
symbol_map = { symbol_map = {
Copilot = '', Copilot = '',
Text = '',
Constructor = '',
}, },
}, },
}, },

View File

@@ -19,9 +19,6 @@ return {
-- Extension to mason.nvim that makes it easier to use lspconfig with mason.nvim. -- Extension to mason.nvim that makes it easier to use lspconfig with mason.nvim.
-- https://github.com/williamboman/mason-lspconfig.nvim -- https://github.com/williamboman/mason-lspconfig.nvim
{ 'williamboman/mason-lspconfig.nvim' }, { 'williamboman/mason-lspconfig.nvim' },
-- Install and upgrade third party tools automatically
-- https://github.com/WhoIsSethDaniel/mason-tool-installer.nvim
{ 'WhoIsSethDaniel/mason-tool-installer.nvim' },
-- ── Formatting ────────────────────────────────────────────────────── -- ── Formatting ──────────────────────────────────────────────────────
-- Lightweight yet powerful formatter plugin for Neovim -- Lightweight yet powerful formatter plugin for Neovim
@@ -30,33 +27,81 @@ return {
'stevearc/conform.nvim', 'stevearc/conform.nvim',
event = { 'BufWritePre' }, event = { 'BufWritePre' },
cmd = { 'ConformInfo' }, cmd = { 'ConformInfo' },
opts = { config = function()
formatters_by_ft = { -- Select first conform formatter that is available
lua = { 'stylua' }, ---@param bufnr integer
-- Conform will run multiple formatters sequentially ---@param ... string
-- python = { 'isort', 'black', lsp_format = 'fallback' }, ---@return string
-- You can customize some of the format options for the filetype (:help conform.format) local function first(bufnr, ...)
-- rust = { 'rustfmt', lsp_format = 'fallback' }, local conform = require 'conform'
-- Conform will run the first available formatter for i = 1, select('#', ...) do
javascript = { 'prettier', 'eslint', stop_after_first = true }, local formatter = select(i, ...)
}, if conform.get_formatter_info(formatter, bufnr).available then
notify_on_error = true, return formatter
format_on_save = function(bufnr) end
-- Disable "format_on_save lsp_fallback" for languages that don't end
-- have a well standardized coding style. You can add additional return select(1, ...)
-- languages here or re-enable it for the disabled ones. end
local disable_filetypes = { c = true, cpp = true }
return { require('conform').setup {
-- formatters = { 'injected' }, -- Enable or disable logging
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], notify_on_error = true,
timeout_ms = 500, -- Set the default formatter for all filetypes
} default_formatter = 'injected',
end, -- Set the default formatter for all filetypes
}, default_formatter_opts = {
lsp_format = 'fallback',
-- Set the default formatter for all filetypes
-- formatter = 'injected',
-- Set the default formatter for all filetypes
-- formatter_opts = {},
},
formatters_by_ft = {
markdown = function(bufnr)
return { first(bufnr, 'prettierd', 'prettier'), 'injected' }
end,
javascript = function(bufnr)
return { first(bufnr, 'prettier', 'eslint'), 'injected' }
end,
lua = { 'stylua' },
-- Conform will run multiple formatters sequentially
-- python = { 'isort', 'black', lsp_format = 'fallback' },
-- You can customize some of the format options for the filetype (:help conform.format)
-- rust = { 'rustfmt', lsp_format = 'fallback' },
},
format_on_save = function(bufnr)
-- Disable autoformat on certain filetypes
local ignore_filetypes = {
'c',
'cpp',
'sql',
'java',
}
if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then
return
end
-- Disable with a global or buffer-local variable
if
vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat
then
return
end
-- Disable autoformat for files in a certain path
local bufname = vim.api.nvim_buf_get_name(bufnr)
if bufname:match '/node_modules/' then return end
if bufname:match '/vendor/' then return end
if bufname:match '/dist/' then return end
if bufname:match '/build/' then return end
return { timeout_ms = 500, lsp_format = 'fallback' }
end,
}
end,
init = function()
-- If you want the formatexpr, here is the place to set it
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}, },
-- Automatically install formatters registered with conform.nvim via mason.nvim
-- https://github.com/zapling/mason-conform.nvim
{ 'zapling/mason-conform.nvim' },
-- ── Misc ──────────────────────────────────────────────────────────── -- ── Misc ────────────────────────────────────────────────────────────
-- vscode-like pictograms for neovim lsp completion items -- vscode-like pictograms for neovim lsp completion items
@@ -82,20 +127,28 @@ return {
---@output nil ---@output nil
local on_attach = function(_, bufnr) local on_attach = function(_, bufnr)
-- Create a command `:Format` local to the LSP buffer -- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) vim.api.nvim_create_user_command('Format', function(args)
require('conform').format { formatters = { 'injected' }, async = true, lsp_fallback = true } local range = nil
if args.count ~= -1 then
-- if vim.lsp.buf.format then local end_line = vim.api.nvim_buf_get_lines(
-- vim.lsp.buf.format() bufnr,
-- elseif vim.lsp.buf.formatting then args.line2 - 1,
-- vim.lsp.buf.formatting() args.line2,
-- end true
end, { desc = 'Format current buffer with LSP' }) )[1]
range = {
start = { args.line1, 0 },
['end'] = { args.line2, end_line:len() },
}
end
require('conform').format {
async = true,
lsp_format = 'fallback',
range = range,
}
end, { range = true, desc = 'Format current buffer with LSP' })
end end
-- ── Setup mason so it can manage external tooling ───────────────────
require('mason').setup()
-- ── Enable the following language servers ─────────────────────────── -- ── Enable the following language servers ───────────────────────────
-- :help lspconfig-all for all pre-configured LSPs -- :help lspconfig-all for all pre-configured LSPs
local servers = { local servers = {
@@ -106,6 +159,7 @@ return {
intelephense = {}, -- PHP intelephense = {}, -- PHP
tailwindcss = {}, -- Tailwind CSS tailwindcss = {}, -- Tailwind CSS
ts_ls = {}, -- TypeScript ts_ls = {}, -- TypeScript
volar = {}, -- Vue
lua_ls = { lua_ls = {
settings = { settings = {
@@ -184,10 +238,10 @@ return {
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, mason_servers) vim.list_extend(ensure_installed, mason_servers)
-- ── Automagically install tools ───────────────────────────────────── -- ── Setup mason so it can manage external tooling ───────────────────
require('mason-tool-installer').setup { require('mason').setup {
ensure_installed = ensure_installed, ensure_installed = ensure_installed,
auto_update = true, automatic_installation = true,
} }
-- nvim-cmp supports additional completion capabilities -- nvim-cmp supports additional completion capabilities
@@ -200,6 +254,15 @@ return {
lineFoldingOnly = true, lineFoldingOnly = true,
} }
capabilities.textDocument.completion.completionItem.snippetSupport = true
capabilities.textDocument.completion.completionItem.resolveSupport = {
properties = {
'documentation',
'detail',
'additionalTextEdits',
},
}
local lspconfig_handlers = { local lspconfig_handlers = {
-- The first entry (without a key) will be the default handler -- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have -- and will be called for each installed server that doesn't have
@@ -211,8 +274,12 @@ return {
} }
end, end,
-- Next, you can provide targeted overrides for specific servers. -- Next, you can provide targeted overrides for specific servers.
['lua_ls'] = function() require('lspconfig')['lua_ls'].setup { settings = servers.lua_ls } end, ['lua_ls'] = function()
['jsonls'] = function() require('lspconfig')['jsonls'].setup { settings = servers.jsonls } end, require('lspconfig')['lua_ls'].setup { settings = servers.lua_ls }
end,
['jsonls'] = function()
require('lspconfig')['jsonls'].setup { settings = servers.jsonls }
end,
} }
require('mason-lspconfig').setup { require('mason-lspconfig').setup {
@@ -220,21 +287,6 @@ return {
automatic_installation = true, automatic_installation = true,
handlers = lspconfig_handlers, handlers = lspconfig_handlers,
} }
vim.api.nvim_create_autocmd('FileType', {
pattern = 'sh',
callback = function()
vim.lsp.start {
name = 'bash-language-server',
cmd = { 'bash-language-server', 'start' },
}
end,
})
-- ── Setup formatting ────────────────────────────────────────────────
require('mason-conform').setup {
-- ignore_install = { 'prettier' }, -- List of formatters to ignore during install
}
end, end,
}, },
@@ -309,80 +361,71 @@ return {
end, end,
}, },
}, },
config = function() opts = {
local capabilities = vim.lsp.protocol.make_client_capabilities() open_fold_hl_timeout = 150,
capabilities.textDocument.foldingRange = { close_fold_kinds_for_ft = { 'imports', 'comment' },
dynamicRegistration = false, preview = {
lineFoldingOnly = true, win_config = {
} border = { '', '', '', '', '', '', '', '' },
local language_servers = require('lspconfig').util.available_servers() -- or list servers manually like {'gopls', 'clangd'} winhighlight = 'Normal:Folded',
for _, ls in ipairs(language_servers) do winblend = 0,
require('lspconfig')[ls].setup {
capabilities = capabilities,
-- you can add other fields for setting up lsp server in this table
}
end
require('ufo').setup {
open_fold_hl_timeout = 150,
close_fold_kinds_for_ft = { 'imports', 'comment' },
preview = {
win_config = {
border = { '', '', '', '', '', '', '', '' },
winhighlight = 'Normal:Folded',
winblend = 0,
},
mappings = {
scrollU = '<C-u>',
scrollD = '<C-d>',
jumpTop = '[',
jumpBot = ']',
},
}, },
mappings = {
scrollU = '<C-u>',
scrollD = '<C-d>',
jumpTop = '[',
jumpBot = ']',
},
},
provider_selector = function(_, _, _) -- bufnr, filetype, buftype provider_selector = function(_, _, _) -- bufnr, filetype, buftype
return { 'treesitter', 'indent' } return { 'treesitter', 'indent' }
end, end,
-- fold_virt_text_handler -- fold_virt_text_handler
-- --
-- This handler is called when the fold text is too long to fit in the window. -- This handler is called when the fold text is too long to fit in the window.
-- It is expected to truncate the text and return a new list of virtual text. -- It is expected to truncate the text and return a new list of virtual text.
-- --
---@param virtText table The current virtual text list. ---@param virtText table The current virtual text list.
---@param lnum number The line number of the first line in the fold. ---@param lnum number The line number of the first line in the fold.
---@param endLnum number The line number of the last line in the fold. ---@param endLnum number The line number of the last line in the fold.
---@param width number The width of the window. ---@param width number The width of the window.
---@param truncate function Truncate function ---@param truncate function Truncate function
---@return table ---@return table
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate) fold_virt_text_handler = function(
local newVirtText = {} virtText,
local suffix = (' 󰁂 %d '):format(endLnum - lnum) lnum,
local sufWidth = vim.fn.strdisplaywidth(suffix) endLnum,
local targetWidth = width - sufWidth width,
local curWidth = 0 truncate
for _, chunk in ipairs(virtText) do )
local chunkText = chunk[1] local newVirtText = {}
local chunkWidth = vim.fn.strdisplaywidth(chunkText) local suffix = (' 󰁂 %d '):format(endLnum - lnum)
if targetWidth > curWidth + chunkWidth then local sufWidth = vim.fn.strdisplaywidth(suffix)
table.insert(newVirtText, chunk) local targetWidth = width - sufWidth
else local curWidth = 0
chunkText = truncate(chunkText, targetWidth - curWidth) for _, chunk in ipairs(virtText) do
local hlGroup = chunk[2] local chunkText = chunk[1]
table.insert(newVirtText, { chunkText, hlGroup }) local chunkWidth = vim.fn.strdisplaywidth(chunkText)
chunkWidth = vim.fn.strdisplaywidth(chunkText) if targetWidth > curWidth + chunkWidth then
-- str width returned from truncate() may less than 2nd argument, need padding table.insert(newVirtText, chunk)
if curWidth + chunkWidth < targetWidth then else
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth) chunkText = truncate(chunkText, targetWidth - curWidth)
end local hlGroup = chunk[2]
break table.insert(newVirtText, { chunkText, hlGroup })
chunkWidth = vim.fn.strdisplaywidth(chunkText)
-- str width returned from truncate() may less than 2nd argument, need padding
if curWidth + chunkWidth < targetWidth then
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
end end
curWidth = curWidth + chunkWidth break
end end
table.insert(newVirtText, { suffix, 'MoreMsg' }) curWidth = curWidth + chunkWidth
return newVirtText end
end, table.insert(newVirtText, { suffix, 'MoreMsg' })
} return newVirtText
end, end,
},
}, },
} }

View File

@@ -2,7 +2,10 @@
-- https://github.com/nvim-treesitter/nvim-treesitter -- https://github.com/nvim-treesitter/nvim-treesitter
return { return {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = function() pcall(require('nvim-treesitter.install').update { with_sync = true }) end, version = false, -- last release is way too old and doesn't work on Windows
build = function()
pcall(require('nvim-treesitter.install').update { with_sync = true })
end,
dependencies = { dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
}, },

View File

@@ -34,18 +34,14 @@ return {
event = 'VimEnter', event = 'VimEnter',
config = function() config = function()
require('dashboard').setup { require('dashboard').setup {
theme = 'doom',
config = { config = {
disable_move = true, disable_move = true,
week_header = { week_header = {
enable = true, enable = true,
}, },
shortcut = { shortcut = {},
{ center = {
desc = '󰊳 Lazy Update',
group = '@property',
action = 'Lazy update',
key = 'u',
},
{ {
icon = '', icon = '',
icon_hl = '@variable', icon_hl = '@variable',
@@ -55,23 +51,33 @@ return {
key = 'f', key = 'f',
}, },
{ {
desc = 'Marks', icon = '',
desc = 'Marks',
group = 'DiagnosticHint', group = 'DiagnosticHint',
action = 'Telescope harpoon marks', action = 'Telescope harpoon marks',
key = 'a', key = 'a',
}, },
{ {
desc = 'TODO', icon = '',
desc = 'TODO',
group = 'DiagnosticOptions', group = 'DiagnosticOptions',
action = 'TodoTelescope', action = 'TodoTelescope',
key = 't', key = 't',
}, },
{ {
desc = '🔍 Search', icon = '',
desc = 'Search',
group = 'Number', group = 'Number',
action = 'Telescope live_grep', action = 'Telescope live_grep',
key = 's', key = 's',
}, },
{
icon = '󰊳 ',
desc = 'Lazy Update',
group = '@property',
action = 'Lazy update',
key = 'u',
},
}, },
}, },
} }
@@ -110,6 +116,7 @@ return {
-- https://github.com/lewis6991/gitsigns.nvim -- https://github.com/lewis6991/gitsigns.nvim
{ {
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
version = false,
lazy = false, lazy = false,
opts = { opts = {
signs = { signs = {
@@ -228,7 +235,10 @@ return {
-- https://github.com/MeanderingProgrammer/render-markdown.nvim -- https://github.com/MeanderingProgrammer/render-markdown.nvim
{ {
'MeanderingProgrammer/render-markdown.nvim', 'MeanderingProgrammer/render-markdown.nvim',
dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, dependencies = {
'nvim-treesitter/nvim-treesitter',
'nvim-tree/nvim-web-devicons',
},
ft = 'markdown', ft = 'markdown',
opts = {}, opts = {},
}, },

View File

@@ -27,31 +27,67 @@ return {
return require('which-key.extras').expand.buf() return require('which-key.extras').expand.buf()
end, end,
}, },
{ '<leader>bk', '<cmd>blast<cr>', desc = 'Buffer: Last' }, {
{ '<leader>bj', '<cmd>bfirst<cr>', desc = 'Buffer: First' }, { '<leader>bk', '<cmd>blast<cr>', desc = 'Buffer: Last' },
{ '<leader>bh', '<cmd>bprev<cr>', desc = 'Buffer: Prev' }, { '<leader>bj', '<cmd>bfirst<cr>', desc = 'Buffer: First' },
{ '<leader>bl', '<cmd>bnext<cr>', desc = 'Buffer: Next' }, { '<leader>bh', '<cmd>bprev<cr>', desc = 'Buffer: Prev' },
{ '<leader>bd', '<cmd>Bdelete<cr>', desc = 'Buffer: Delete' }, { '<leader>bl', '<cmd>bnext<cr>', desc = 'Buffer: Next' },
{ '<leader>bw', '<cmd>Bwipeout<cr>', desc = 'Buffer: Wipeout' }, { '<leader>bd', '<cmd>Bdelete<cr>', desc = 'Buffer: Delete' },
{ '<leader>bw', '<cmd>Bwipeout<cr>', desc = 'Buffer: Wipeout' },
},
-- ── Code ──────────────────────────────────────────────────────────── -- ── Code ────────────────────────────────────────────────────────────
{ '<leader>c', group = '[c] Code' }, { '<leader>c', group = '[c] Code' },
{ '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', desc = 'LSP: Code Action' }, {
{ '<leader>cg', '<cmd>lua require("neogen").generate()<CR>', desc = 'Generate annotations' }, {
'<leader>ca',
'<cmd>lua vim.lsp.buf.code_action()<CR>',
desc = 'LSP: Code Action',
},
{
'<leader>cg',
'<cmd>lua require("neogen").generate()<CR>',
desc = 'Generate annotations',
},
},
-- ── Code: CommentBox ──────────────────────────────────────────────── -- ── Code: CommentBox ────────────────────────────────────────────────
{ '<leader>cb', group = 'CommentBox' }, {
{ '<leader>cbb', '<Cmd>CBccbox<CR>', desc = 'CommentBox: Box Title' }, { '<leader>cb', group = 'CommentBox' },
{ '<leader>cbd', '<Cmd>CBd<CR>', desc = 'CommentBox: Remove a box' }, { '<leader>cbb', '<Cmd>CBccbox<CR>', desc = 'CommentBox: Box Title' },
{ '<leader>cbl', '<Cmd>CBline<CR>', desc = 'CommentBox: Simple Line' }, { '<leader>cbd', '<Cmd>CBd<CR>', desc = 'CommentBox: Remove a box' },
{ '<leader>cbm', '<Cmd>CBllbox14<CR>', desc = 'CommentBox: Marked' }, { '<leader>cbl', '<Cmd>CBline<CR>', desc = 'CommentBox: Simple Line' },
{ '<leader>cbt', '<Cmd>CBllline<CR>', desc = 'CommentBox: Titled Line' }, { '<leader>cbm', '<Cmd>CBllbox14<CR>', desc = 'CommentBox: Marked' },
{
'<leader>cbt',
'<Cmd>CBllline<CR>',
desc = 'CommentBox: Titled Line',
},
},
-- ── Code: package.json control ────────────────────────────────────── -- ── Code: package.json control ──────────────────────────────────────
-- See: lua/plugins/lazy.lua -- See: lua/plugins/lazy.lua
{ '<leader>cn', group = 'package.json control' }, { '<leader>cn', group = 'package.json control' },
{ '<leader>cnd', '<cmd>lua require("package-info").delete()<cr>', desc = 'Delete package' }, {
{ '<leader>cni', '<cmd>lua require("package-info").install()<cr>', desc = 'Install package' }, {
{ '<leader>cns', '<cmd>lua require("package-info").show({ force = true })<cr>', desc = 'Show package info' }, '<leader>cnd',
{ '<leader>cnu', '<cmd>lua require("package-info").change_version()<cr>', desc = 'Change version' }, '<cmd>lua require("package-info").delete()<cr>',
desc = 'Delete package',
},
{
'<leader>cni',
'<cmd>lua require("package-info").install()<cr>',
desc = 'Install package',
},
{
'<leader>cns',
'<cmd>lua require("package-info").show({ force = true })<cr>',
desc = 'Show package info',
},
{
'<leader>cnu',
'<cmd>lua require("package-info").change_version()<cr>',
desc = 'Change version',
},
},
-- ── Code: Refactoring ─────────────────────────────────────────────── -- ── Code: Refactoring ───────────────────────────────────────────────
{ '<leader>cx', group = '[x] Refactoring' }, { '<leader>cx', group = '[x] Refactoring' },
@@ -77,7 +113,7 @@ return {
}, },
-- Inline func supports only normal -- Inline func supports only normal
{ {
'<leader>cxi', '<leader>cxif',
"<cmd>lua require('refactoring').refactor('Inline Function')<cr>", "<cmd>lua require('refactoring').refactor('Inline Function')<cr>",
desc = 'Inline Function', desc = 'Inline Function',
}, },
@@ -96,7 +132,7 @@ return {
mode = { 'n', 'x' }, mode = { 'n', 'x' },
-- Inline var supports both normal and visual mode -- Inline var supports both normal and visual mode
{ {
'<leader>cxi', '<leader>cxiv',
"<cmd>lua require('refactoring').refactor('Inline Variable')<cr>", "<cmd>lua require('refactoring').refactor('Inline Variable')<cr>",
desc = 'Inline Variable', desc = 'Inline Variable',
}, },
@@ -104,49 +140,141 @@ return {
-- ── Code: LSPSaga ─────────────────────────────────────────────────── -- ── Code: LSPSaga ───────────────────────────────────────────────────
-- See: lua/plugins/lsp.lua -- See: lua/plugins/lsp.lua
{ '<C-a>', '<cmd>Lspsaga term_toggle<cr>', desc = 'LSPSaga: Open Floaterm' }, {
{ '<leader>ca', '<cmd>Lspsaga code_action<cr>', desc = 'LSPSaga: Code Actions' }, '<C-a>',
{ '<leader>cci', '<cmd>Lspsaga incoming_calls<cr>', desc = 'LSPSaga: Incoming Calls' }, '<cmd>Lspsaga term_toggle<cr>',
{ '<leader>cco', '<cmd>Lspsaga outgoing_calls<cr>', desc = 'LSPSaga: Outgoing Calls' }, desc = 'LSPSaga: Open Floaterm',
{ '<leader>cd', '<cmd>Lspsaga show_line_diagnostics<cr>', desc = 'LSPSaga: Show Line Diagnostics' }, },
{
'<leader>ca',
'<cmd>Lspsaga code_action<cr>',
desc = 'LSPSaga: Code Actions',
},
{
'<leader>cci',
'<cmd>Lspsaga incoming_calls<cr>',
desc = 'LSPSaga: Incoming Calls',
},
{
'<leader>cco',
'<cmd>Lspsaga outgoing_calls<cr>',
desc = 'LSPSaga: Outgoing Calls',
},
{
'<leader>cd',
'<cmd>Lspsaga show_line_diagnostics<cr>',
desc = 'LSPSaga: Show Line Diagnostics',
},
{ {
'<leader>cf', '<leader>cf',
'<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>', '<cmd>lua require("conform").format({ async = true, lsp_fallback = true })<cr>',
mode = { 'n', 'v' }, mode = { 'n', 'v' },
desc = 'Format buffer', desc = 'Format buffer',
}, },
{ '<leader>ci', '<cmd>Lspsaga implement<cr>', desc = 'LSPSaga: Implementations' }, {
{ '<leader>cl', '<cmd>Lspsaga show_cursor_diagnostics<cr>', desc = 'LSPSaga: Show Cursor Diagnostics' }, '<leader>ci',
{ '<leader>cp', '<cmd>Lspsaga peek_definition<cr>', desc = 'LSPSaga: Peek Definition' }, '<cmd>Lspsaga implement<cr>',
desc = 'LSPSaga: Implementations',
},
{
'<leader>cl',
'<cmd>Lspsaga show_cursor_diagnostics<cr>',
desc = 'LSPSaga: Show Cursor Diagnostics',
},
{
'<leader>cp',
'<cmd>Lspsaga peek_definition<cr>',
desc = 'LSPSaga: Peek Definition',
},
{ '<leader>cr', '<cmd>Lspsaga rename<cr>', desc = 'LSPSaga: Rename' }, { '<leader>cr', '<cmd>Lspsaga rename<cr>', desc = 'LSPSaga: Rename' },
{ '<leader>cR', '<cmd>Lspsaga rename ++project<cr>', desc = 'LSPSaga: Rename Project wide' }, {
{ '<leader>cs', '<cmd>Lspsaga signature_help<cr>', desc = 'LSPSaga: Signature Documentation' }, '<leader>cR',
{ '<leader>ct', '<cmd>Lspsaga peek_type_definition<cr>', desc = 'LSPSaga: Peek Type Definition' }, '<cmd>Lspsaga rename ++project<cr>',
{ '<leader>cu', '<cmd>Lspsaga preview_definition<cr>', desc = 'LSPSaga: Preview Definition' }, desc = 'LSPSaga: Rename Project wide',
{ '<leader>cv', '<cmd>Lspsaga diagnostic_jump_prev<cr>', desc = 'LSPSaga: Diagnostic Jump Prev' }, },
{ '<leader>cw', '<cmd>Lspsaga diagnostic_jump_next<cr>', desc = 'LSPSaga: Diagnostic Jump Next' }, {
'<leader>cs',
'<cmd>Lspsaga signature_help<cr>',
desc = 'LSPSaga: Signature Documentation',
},
{
'<leader>ct',
'<cmd>Lspsaga peek_type_definition<cr>',
desc = 'LSPSaga: Peek Type Definition',
},
{
'<leader>cu',
'<cmd>Lspsaga preview_definition<cr>',
desc = 'LSPSaga: Preview Definition',
},
{
'<leader>cv',
'<cmd>Lspsaga diagnostic_jump_prev<cr>',
desc = 'LSPSaga: Diagnostic Jump Prev',
},
{
'<leader>cw',
'<cmd>Lspsaga diagnostic_jump_next<cr>',
desc = 'LSPSaga: Diagnostic Jump Next',
},
-- ── DAP ───────────────────────────────────────────────────────────── -- ── DAP ─────────────────────────────────────────────────────────────
{ '<leader>d', group = '[d] DAP' }, { '<leader>d', group = '[d] DAP' },
{ '<leader>db', '<cmd>DapToggleBreakpoint', desc = 'DAP: Toggle Breakpoint' },
{ '<leader>dc', '<cmd>DapContinue', desc = 'DAP: Continue' },
{ '<leader>do', '<cmd>lua vim.diagnostic.open_float()<CR>', desc = 'Diagnostic: Open float' },
{ '<leader>dq', '<cmd>lua vim.diagnostic.setloclist()<CR>', desc = 'Diagnostic: Set loc list' },
{ '<leader>dr', "<cmd>lua require('dapui').open({reset = true})<CR>", desc = 'DAP: Reset' },
{ {
'<leader>ds', {
'<cmd>lua require("telescope.builtin").lsp_document_symbols()<CR>', '<leader>db',
desc = 'LSP: Document Symbols', '<cmd>DapToggleBreakpoint',
desc = 'DAP: Toggle Breakpoint',
},
{ '<leader>dc', '<cmd>DapContinue', desc = 'DAP: Continue' },
{
'<leader>do',
'<cmd>lua vim.diagnostic.open_float()<CR>',
desc = 'Diagnostic: Open float',
},
{
'<leader>dq',
'<cmd>lua vim.diagnostic.setloclist()<CR>',
desc = 'Diagnostic: Set loc list',
},
{
'<leader>dr',
"<cmd>lua require('dapui').open({reset = true})<CR>",
desc = 'DAP: Reset',
},
{
'<leader>ds',
'<cmd>lua require("telescope.builtin").lsp_document_symbols()<CR>',
desc = 'LSP: Document Symbols',
},
{ '<leader>dt', '<cmd>DapUiToggle', desc = 'DAP: Toggle UI' },
}, },
{ '<leader>dt', '<cmd>DapUiToggle', desc = 'DAP: Toggle UI' },
-- ── Harpoon ───────────────────────────────────────────────────────── -- ── Harpoon ─────────────────────────────────────────────────────────
-- See: lua/plugins/telescope.lua -- See: lua/plugins/telescope.lua
{ '<leader>h', group = '[h] Harpoon' }, { '<leader>h', group = '[h] Harpoon' },
{ '<leader>ha', '<cmd>lua require("harpoon"):list():add()<cr>', desc = 'harpoon file' }, {
{ '<leader>hn', '<cmd>lua require("harpoon"):list():next()<cr>', desc = 'harpoon to next file' }, {
{ '<leader>hp', '<cmd>lua require("harpoon"):list():prev()<cr>', desc = 'harpoon to previous file' }, '<leader>ha',
{ '<leader>ht', "<cmd>lua require('harpoon.ui').toggle_quick_menu()<CR>", desc = 'DAP: Harpoon UI' }, '<cmd>lua require("harpoon"):list():add()<cr>',
desc = 'harpoon file',
},
{
'<leader>hn',
'<cmd>lua require("harpoon"):list():next()<cr>',
desc = 'harpoon to next file',
},
{
'<leader>hp',
'<cmd>lua require("harpoon"):list():prev()<cr>',
desc = 'harpoon to previous file',
},
{
'<leader>ht',
"<cmd>lua require('harpoon.ui').toggle_quick_menu()<CR>",
desc = 'DAP: Harpoon UI',
},
},
-- ── LSP ───────────────────────────────────────────────────────────── -- ── LSP ─────────────────────────────────────────────────────────────
{ '<leader>l', group = '[l] LSP' }, { '<leader>l', group = '[l] LSP' },
@@ -154,74 +282,164 @@ return {
-- ── Quit ──────────────────────────────────────────────────────────── -- ── Quit ────────────────────────────────────────────────────────────
{ '<leader>q', group = '[q] Quit' }, { '<leader>q', group = '[q] Quit' },
{ '<leader>qf', '<cmd>q<CR>', desc = 'Quicker close split' }, {
{ '<leader>qq', '<cmd>wq!<CR>', desc = 'Quit with force saving' }, { '<leader>qf', '<cmd>q<CR>', desc = 'Quicker close split' },
{ '<leader>qw', '<cmd>wq<CR>', desc = 'Write and quit' }, { '<leader>qq', '<cmd>wq!<CR>', desc = 'Quit with force saving' },
{ '<leader>qw', '<cmd>wq<CR>', desc = 'Write and quit' },
},
-- ── Search ────────────────────────────────────────────────────────── -- ── Search ──────────────────────────────────────────────────────────
{ '<leader>s', group = '[s] Search' }, { '<leader>s', group = '[s] Search' },
-- See: lua/plugins/telescope.lua -- See: lua/plugins/telescope.lua
{ '<leader><space>', "<cmd>lua require('telescope.builtin').buffers()<cr>", desc = 'Find existing buffers' }, {
{ '<leader><tab>', "<cmd>lua require('telescope.builtin').commands()<CR>", desc = 'Telescope: Commands' }, '<leader><space>',
{ '<leader>sd', "<cmd>lua require('telescope.builtin').diagnostics()<cr>", desc = 'Search Diagnostics' }, "<cmd>lua require('telescope.builtin').buffers()<cr>",
{ '<leader>sg', "<cmd>lua require('telescope.builtin').live_grep()<cr>", desc = 'Search by Grep' }, desc = 'Find existing buffers',
{ '<leader>sm', '<cmd>Telescope harpoon marks<CR>', desc = 'Harpoon Marks' }, },
{ '<leader>sn', "<cmd>lua require('telescope').extensions.notify.notify()<CR>", desc = 'Notify' }, {
{ '<leader>so', "<cmd>lua require('telescope.builtin').oldfiles()<cr>", desc = 'Find recently Opened files' }, '<leader><tab>',
"<cmd>lua require('telescope.builtin').commands()<CR>",
desc = 'Telescope: Commands',
},
{
'<leader>sd',
"<cmd>lua require('telescope.builtin').diagnostics()<cr>",
desc = 'Search Diagnostics',
},
{
'<leader>sg',
"<cmd>lua require('telescope.builtin').live_grep()<cr>",
desc = 'Search by Grep',
},
{
'<leader>sm',
'<cmd>Telescope harpoon marks<CR>',
desc = 'Harpoon Marks',
},
{
'<leader>sn',
"<cmd>lua require('telescope').extensions.notify.notify()<CR>",
desc = 'Show Notifications',
},
{
'<leader>so',
"<cmd>lua require('telescope.builtin').oldfiles()<cr>",
desc = 'Find recently Opened files',
},
{ {
'<leader>sp', '<leader>sp',
"<cmd>lua require('telescope').extensions.lazy_plugins.lazy_plugins()<cr>", "<cmd>lua require('telescope').extensions.lazy_plugins.lazy_plugins()<cr>",
desc = 'Find neovim/lazy configs', desc = 'Find neovim/lazy configs',
}, },
{ '<leader>st', '<cmd>TodoTelescope<CR>', desc = 'Telescope: Todo' }, { '<leader>st', '<cmd>TodoTelescope<CR>', desc = 'Telescope: Show Todo' },
{ '<leader>sw', "<cmd>lua require('telescope.builtin').grep_string()<cr>", desc = 'Search current Word' }, {
'<leader>sw',
"<cmd>lua require('telescope.builtin').grep_string()<cr>",
desc = 'Search current Word',
},
-- ── Toggle ────────────────────────────────────────────────────────── -- ── Toggle ──────────────────────────────────────────────────────────
{ '<leader>t', group = '[t] Toggle' }, { '<leader>t', group = '[t] Toggle' },
{ '<leader>tc', '<cmd>CloakToggle<cr>', desc = 'Toggle Cloak' }, {
{ '<leader>tn', '<cmd>Noice dismiss<CR>', desc = 'Noice dismiss' }, { '<leader>tc', '<cmd>CloakToggle<cr>', desc = 'Toggle Cloak' },
{ '<leader>ts', '<cmd>noh<CR>', desc = 'Toggle Search Highlighting' }, { '<leader>tn', '<cmd>Noice dismiss<CR>', desc = 'Noice dismiss' },
{ '<leader>tt', '<cmd>TransparentToggle<CR>', desc = 'Toggle Transparency' }, { '<leader>ts', '<cmd>noh<CR>', desc = 'Toggle Search Highlighting' },
{ '<leader>tw', '<cmd>Twilight<cr>', desc = 'Toggle Twilight' }, {
'<leader>tt',
'<cmd>TransparentToggle<CR>',
desc = 'Toggle Transparency',
},
{ '<leader>tw', '<cmd>Twilight<cr>', desc = 'Toggle Twilight' },
},
-- ── Workspace ─────────────────────────────────────────────────────── -- ── Workspace ───────────────────────────────────────────────────────
{ '<leader>w', group = '[w] Workspace' }, { '<leader>w', group = '[w] Workspace' },
{ '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', desc = 'LSP: Workspace Add Folder' },
{ {
'<leader>wl', {
'<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', '<leader>wa',
desc = 'LSP: Workspace List Folders', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>',
}, desc = 'LSP: Workspace Add Folder',
{ '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', desc = 'LSP: Workspace Remove Folder' }, },
{ {
'<leader>ws', '<leader>wl',
'<cmd>lua require("telescope.builtin").lsp_dynamic_workspace_symbols()<CR>', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>',
desc = 'LSP: Workspace Symbols', desc = 'LSP: Workspace List Folders',
},
{
'<leader>wr',
'<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>',
desc = 'LSP: Workspace Remove Folder',
},
{
'<leader>ws',
'<cmd>lua require("telescope.builtin").lsp_dynamic_workspace_symbols()<CR>',
desc = 'LSP: Workspace Symbols',
},
}, },
-- ── Trouble ───────────────────────────────────────────────────────── -- ── Trouble ─────────────────────────────────────────────────────────
{ '<leader>x', group = '[x] Trouble' }, { '<leader>x', group = '[x] Trouble' },
{ '<leader>xx', '<cmd>Trouble<cr>', desc = 'Toggle Trouble' }, {
{ '<leader>xw', '<cmd>Trouble workspace_diagnostics<cr>', desc = 'Toggle Workspace Diagnostics' }, {
{ '<leader>xd', '<cmd>Trouble document_diagnostics<cr>', desc = 'Toggle Document Diagnostics' }, '<leader>xx',
{ '<leader>xl', '<cmd>Trouble loclist<cr>', desc = 'Toggle Loclist' }, '<cmd>Trouble diagnostics<cr>',
{ '<leader>xq', '<cmd>Trouble quickfix<cr>', desc = 'Toggle Quickfix' }, desc = 'Toggle Trouble Diagnostics',
},
{
'<leader>xw',
'<cmd>Trouble workspace_diagnostics<cr>',
desc = 'Toggle Workspace Diagnostics',
},
{
'<leader>xd',
'<cmd>Trouble document_diagnostics<cr>',
desc = 'Toggle Document Diagnostics',
},
{ '<leader>xl', '<cmd>Trouble loclist<cr>', desc = 'Toggle Loclist' },
{ '<leader>xq', '<cmd>Trouble quickfix<cr>', desc = 'Toggle Quickfix' },
},
-- ── Help ──────────────────────────────────────────────────────────── -- ── Help ────────────────────────────────────────────────────────────
{ '<leader>?', group = '[?] Help & Cheat sheets' }, { '<leader>?', group = '[?] Help & Cheat sheets' },
{ {
'<leader>?w', {
'<cmd>lua require("which-key").show({global = false})<cr>', '<leader>?w',
desc = 'Buffer Local Keymaps (which-key)', '<cmd>lua require("which-key").show({global = false})<cr>',
desc = 'Buffer Local Keymaps (which-key)',
},
}, },
-- ── Misc ──────────────────────────────────────────────────────────── -- ── Misc ────────────────────────────────────────────────────────────
{ '<leader>1', '<cmd>lua require("harpoon"):list():select(1)<cr>', desc = 'harpoon to file 1' }, {
{ '<leader>2', '<cmd>lua require("harpoon"):list():select(2)<cr>', desc = 'harpoon to file 2' }, '<leader>1',
{ '<leader>3', '<cmd>lua require("harpoon"):list():select(3)<cr>', desc = 'harpoon to file 3' }, '<cmd>lua require("harpoon"):list():select(1)<cr>',
{ '<leader>4', '<cmd>lua require("harpoon"):list():select(4)<cr>', desc = 'harpoon to file 4' }, desc = 'harpoon to file 1',
{ '<leader>5', '<cmd>lua require("harpoon"):list():select(5)<cr>', desc = 'harpoon to file 5' }, },
{ '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', desc = 'LSP: Type Definition' }, {
'<leader>2',
'<cmd>lua require("harpoon"):list():select(2)<cr>',
desc = 'harpoon to file 2',
},
{
'<leader>3',
'<cmd>lua require("harpoon"):list():select(3)<cr>',
desc = 'harpoon to file 3',
},
{
'<leader>4',
'<cmd>lua require("harpoon"):list():select(4)<cr>',
desc = 'harpoon to file 4',
},
{
'<leader>5',
'<cmd>lua require("harpoon"):list():select(5)<cr>',
desc = 'harpoon to file 5',
},
{
'<leader>D',
'<cmd>lua vim.lsp.buf.type_definition()<CR>',
desc = 'LSP: Type Definition',
},
{ '<leader>e', '<cmd>Neotree reveal<CR>', desc = 'NeoTree reveal' }, { '<leader>e', '<cmd>Neotree reveal<CR>', desc = 'NeoTree reveal' },
-- ╭─────────────────────────────────────────────────────────╮ -- ╭─────────────────────────────────────────────────────────╮
@@ -230,16 +448,48 @@ return {
{ 'y', group = 'Yank & Surround' }, { 'y', group = 'Yank & Surround' },
{ 'gp', group = 'Goto Preview' }, { 'gp', group = 'Goto Preview' },
{ 'gpd', '<cmd>lua require("goto-preview").goto_preview_definition()<CR>' }, {
{ 'gpi', '<cmd>lua require("goto-preview").goto_preview_implementation()<CR>' }, {
{ 'gpP', '<cmd>lua require("goto-preview").close_all_windows()<CR>' }, 'gpd',
'<cmd>lua require("goto-preview").goto_preview_definition()<CR>',
desc = 'Goto: Preview Definition',
},
{
'gpi',
'<cmd>lua require("goto-preview").goto_preview_implementation()<CR>',
desc = 'Goto: Preview Implementation',
},
{
'gpP',
'<cmd>lua require("goto-preview").close_all_windows()<CR>',
desc = 'Goto: Close All Preview Windows',
},
},
-- ── tmux navigation ───────────────────────────────────────────────── -- ── tmux navigation ─────────────────────────────────────────────────
{ '<c-h>', '<cmd><C-U>TmuxNavigateLeft<cr>', desc = 'tmux: Navigate Left' }, {
{ '<c-j>', '<cmd><C-U>TmuxNavigateDown<cr>', desc = 'tmux: Navigate Down' }, {
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>', desc = 'tmux: Navigate Up' }, '<c-h>',
{ '<c-l>', '<cmd><C-U>TmuxNavigateRight<cr>', desc = 'tmux: Navigate Right' }, '<cmd><C-U>TmuxNavigateLeft<cr>',
{ '<c-\\>', '<cmd><C-U>TmuxNavigatePrevious<cr>', desc = 'tmux: Navigate Previous' }, desc = 'tmux: Navigate Left',
},
{
'<c-j>',
'<cmd><C-U>TmuxNavigateDown<cr>',
desc = 'tmux: Navigate Down',
},
{ '<c-k>', '<cmd><C-U>TmuxNavigateUp<cr>', desc = 'tmux: Navigate Up' },
{
'<c-l>',
'<cmd><C-U>TmuxNavigateRight<cr>',
desc = 'tmux: Navigate Right',
},
{
'<c-\\>',
'<cmd><C-U>TmuxNavigatePrevious<cr>',
desc = 'tmux: Navigate Previous',
},
},
-- ── Old habits ────────────────────────────────────────────────────── -- ── Old habits ──────────────────────────────────────────────────────
{ '<C-s>', '<cmd>w<CR>', desc = 'Save file' }, { '<C-s>', '<cmd>w<CR>', desc = 'Save file' },
@@ -254,23 +504,75 @@ return {
}, },
-- ── LSP ───────────────────────────────────────────────────────────── -- ── LSP ─────────────────────────────────────────────────────────────
{ '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', desc = 'LSP: Signature Documentation' }, {
{ 'K', '<cmd>Lspsaga hover_doc<cr>', desc = 'LSPSaga: Hover Documentation' }, '<C-k>',
{ 'dn', '<cmd>lua vim.diagnostic.goto_next()<CR>', desc = 'Diagnostic: Goto Next' }, '<cmd>lua vim.lsp.buf.signature_help()<CR>',
{ 'dp', '<cmd>lua vim.diagnostic.goto_prev()<CR>', desc = 'Diagnostic: Goto Prev' }, desc = 'LSP: Signature Documentation',
{ 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', desc = 'LSP: Goto Declaration' }, },
{ 'gI', '<cmd>lua vim.lsp.buf.implementation()<CR>', desc = 'LSP: Goto Implementation' }, {
{ 'gR', '<cmd>Trouble lsp_references<cr>', desc = 'Toggle LSP References' }, 'K',
{ 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', desc = 'LSP: Goto Definition' }, '<cmd>Lspsaga hover_doc<cr>',
{ 'gr', '<cmd>lua require("telescope.builtin").lsp_references()<CR>', desc = 'LSP: Goto References' }, desc = 'LSPSaga: Hover Documentation',
},
{ 'd', group = 'Diagnostics' },
{
{
'dn',
'<cmd>lua vim.diagnostic.goto_next()<CR>',
desc = 'Diagnostic: Goto Next',
},
{
'dp',
'<cmd>lua vim.diagnostic.goto_prev()<CR>',
desc = 'Diagnostic: Goto Prev',
},
},
{
{ 'g', group = 'Goto' },
{
'gD',
'<cmd>lua vim.lsp.buf.declaration()<CR>',
desc = 'LSP: Goto Declaration',
},
{
'gI',
'<cmd>lua vim.lsp.buf.implementation()<CR>',
desc = 'LSP: Goto Implementation',
},
{
'gR',
'<cmd>Trouble lsp_references<cr>',
desc = 'Toggle LSP References',
},
{
'gd',
'<cmd>lua vim.lsp.buf.definition()<CR>',
desc = 'LSP: Goto Definition',
},
{
'gr',
'<cmd>lua require("telescope.builtin").lsp_references()<CR>',
desc = 'LSP: Goto References',
},
},
-- ── Misc keybinds ─────────────────────────────────────────────────── -- ── Misc keybinds ───────────────────────────────────────────────────
-- Sublime-like shortcut 'go to file' ctrl+p. -- Sublime-like shortcut 'go to file' ctrl+p.
{ '<C-p>', '<cmd>Telescope find_files<CR>', desc = 'Search for files starting at current directory.' }, {
'<C-p>',
'<cmd>Telescope find_files<CR>',
desc = 'Search for files starting at current directory.',
},
{ 'QQ', '<cmd>q!<CR>', desc = 'Quit without saving' }, { 'QQ', '<cmd>q!<CR>', desc = 'Quit without saving' },
{ 'WW', '<cmd>w!<CR>', desc = 'Force write to file' }, { 'WW', '<cmd>w!<CR>', desc = 'Force write to file' },
{ 'ss', '<cmd>noh<CR>', desc = 'Clear Search Highlighting' }, { 'ss', '<cmd>noh<CR>', desc = 'Clear Search Highlighting' },
{ 'jj', '<Esc>', desc = 'Esc without touching esc in insert mode', mode = 'i' }, {
'jj',
'<Esc>',
desc = 'Esc without touching esc in insert mode',
mode = 'i',
},
-- ── Splits ────────────────────────────────────────────────────────── -- ── Splits ──────────────────────────────────────────────────────────
-- Use CTRL+<hjkl> to switch between windows in normal mode -- Use CTRL+<hjkl> to switch between windows in normal mode
@@ -290,12 +592,13 @@ return {
{ '<down>', '<cmd>echo "Use j to move!!"<CR>' }, { '<down>', '<cmd>echo "Use j to move!!"<CR>' },
-- ── Terminal ──────────────────────────────────────────────────────── -- ── Terminal ────────────────────────────────────────────────────────
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier -- Exit terminal mode in the builtin terminal with a shortcut that is
-- for people to discover. Otherwise, you normally need to press <C-\><C-n>, which -- a bit easier for people to discover. Otherwise, you normally need
-- is not what someone will guess without a bit more experience. -- to press <C-\><C-n>, which is not what someone will guess without
-- a bit more experience.
-- --
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- NOTE: This won't work in all terminal emulators/tmux/etc.
-- or just use <C-\><C-n> to exit terminal mode. -- Try your own mapping or just use <C-\><C-n> to exit terminal mode.
{ '<Esc><Esc>', '<C-\\><C-n>', desc = 'Exit terminal mode', mode = 't' }, { '<Esc><Esc>', '<C-\\><C-n>', desc = 'Exit terminal mode', mode = 't' },
-- ── Search ────────────────────────────────────────────────────────── -- ── Search ──────────────────────────────────────────────────────────