nvim: use Global.* key binds in psoxizsh.plugins

This commit is contained in:
Paul Stemmet 2024-08-18 14:13:53 +00:00
parent 69a424a081
commit 055ce78bbd
Signed by: Paul Stemmet
GPG Key ID: EDEA539F594E7E75
3 changed files with 54 additions and 35 deletions

View File

@ -1,3 +1,4 @@
local keys = require 'psoxizsh.key.binds'
return {
-- Disables search highlights when not searching
@ -47,9 +48,9 @@ return {
}
},
keys = {
{ '<C-Left>' , '<cmd>Neotree toggle reveal position=left<CR>' , desc = 'Open FileExplorer' },
{ '<leader><Tab>' , '<cmd>Neotree toggle reveal float source=buffers<CR>' , desc = 'Open Buffers' },
{ '<leader>gs' , '<cmd>Neotree float git_status<CR>' , desc = 'GitStatus Float' },
keys.Global.Super.FileBrowser:as { 'lazy', action = '<cmd>Neotree toggle reveal position=left<CR>' },
keys.Global.ToggleBuffers:as { 'lazy', action = '<cmd>Neotree toggle reveal float source=buffers<CR>' },
keys.Global.ToggleGitStatus:as { 'lazy', action = '<cmd>Neotree float git_status<CR>' },
},
},
@ -57,13 +58,15 @@ return {
{ 'nvim-telescope/telescope.nvim',
branch = '0.1.x',
opts = {
mappings = { i = {
['<C-Right>'] = 'close',
}}
defaults = {
mappings = { i = {
[keys.Global.Super.FuzzySearch.Key] = 'close'
}}
}
},
keys = {
{ '<C-Right>' , '<cmd>Telescope builtin<CR>' , desc = 'Open FuzzyFinder' },
{ '<leader>,' , false },
keys.Global.Super.FuzzySearch:as { 'lazy', action = '<cmd>Telescope builtin<CR>' },
{ '<leader>,' , false },
}
},
@ -71,7 +74,7 @@ return {
{ 'folke/trouble.nvim',
dependencies = { 'kyazdani42/nvim-web-devicons' },
keys = {
{ '<C-Down>' , '<cmd>Trouble diagnostics toggle<CR>' , desc = 'Open Diagnostics' },
keys.Global.Super.Diagnostics:as { 'lazy', action = '<cmd>Trouble diagnostics toggle<CR>' },
},
},
@ -79,13 +82,16 @@ return {
{ 'akinsho/toggleterm.nvim',
version = '^2.0',
opts = {
open_mapping = '<C-Up>',
open_mapping = keys.Global.Super.Terminal.Key,
start_in_insert = true,
insert_mappings = false,
terminal_mappings = true,
direction = 'float',
float_opts = { border = 'curved' },
},
keys = {
keys.Global.Super.Terminal:as { 'lazy', action = '<cmd>ToggleTerm<CR>' },
},
},
-- Tmux integration for pane movement
@ -96,10 +102,10 @@ return {
vim.g['tmux_navigator_disable_when_zoomed'] = 1
end,
keys = {
{ '<C-k>' , '<cmd>TmuxNavigateUp<CR>' , desc = 'Navigate up one window' },
{ '<C-h>' , '<cmd>TmuxNavigateLeft<CR>' , desc = 'Navigate left one window' },
{ '<C-l>' , '<cmd>TmuxNavigateRight<CR>' , desc = 'Navigate right one window' },
{ '<C-j>' , '<cmd>TmuxNavigateDown<CR>' , desc = 'Navigate down one window' },
keys.Global.NavigateUp:as { 'lazy', action = '<cmd>TmuxNavigateUp<CR>' },
keys.Global.NavigateLeft:as { 'lazy', action = '<cmd>TmuxNavigateLeft<CR>' },
keys.Global.NavigateRight:as { 'lazy', action = '<cmd>TmuxNavigateRight<CR>' },
keys.Global.NavigateDown:as { 'lazy', action = '<cmd>TmuxNavigateDown<CR>' },
},
},

View File

@ -1,4 +1,5 @@
-- IDE components, autocompletion, DAPs
local keys = require 'psoxizsh.key.binds'
return {
-- Autocompletion + snippets + vim.diagnostic sources
@ -16,6 +17,7 @@ return {
},
opts = function(_, opts)
local cmp = require('cmp')
local keys = keys.Global.AutoComplete ---@diagnostic disable-line: redefined-local
local auto_select = true
local has_words_before = function()
@ -28,7 +30,7 @@ return {
opts.completion = { completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect") }
opts.mapping = cmp.mapping.preset.insert({
['<Tab>'] = cmp.mapping(function(fallback)
[keys.Next.Key] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif vim.snippet.active({ direction = 1 }) then
@ -39,7 +41,7 @@ return {
fallback()
end
end, { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(function(fallback)
[keys.Prev.Key] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif vim.snippet.active({ direction = -1 }) then
@ -48,15 +50,12 @@ return {
fallback()
end
end, { 'i', 's' }),
['<PageUp>'] = cmp.mapping.scroll_docs(-4),
['<PageDown>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<CR>'] = LazyVim.cmp.confirm({ select = auto_select }),
['<S-CR>'] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
['<C-CR>'] = function(fallback)
cmp.abort()
fallback()
end,
[keys.ScrollUp.Key] = cmp.mapping.scroll_docs(-4),
[keys.ScrollDown.Key] = cmp.mapping.scroll_docs(4),
[keys.Trigger.Key] = cmp.mapping.complete(),
[keys.Confirm.Key] = LazyVim.cmp.confirm({ select = auto_select }),
['<S-CR>'] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
[keys.Abort.Key] = function(fallback) cmp.abort() ; fallback() end,
})
-- Monkey patch the sources list LazyVim sets by default
@ -123,7 +122,23 @@ return {
-- Framework for integrating non-LSP sources into nvim's LSP framework
{ import = 'lazyvim.plugins.extras.lsp.none-ls' },
{ 'nvimtools/none-ls.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'davidmh/cspell.nvim' },
opts = function(_, _)
LazyVim.on_very_lazy(function()
local lazyfmt = require 'lazyvim.util.format'
-- Remove the none-ls formatter, as we only want LazyVim to initialize
-- none-ls, not register it as a formatter
for i, formatter in ipairs(lazyfmt.formatters) do
if formatter.name == 'none-ls.nvim' then
table.remove(lazyfmt.formatters, i)
break
end
end
end)
end
},
{ 'nvimtools/none-ls.nvim',
dependencies = { 'davidmh/cspell.nvim' },
opts = function(_, opts)
if vim.fn.executable('cspell') == 0 then return end
@ -163,5 +178,4 @@ return {
})
end,
},
{ 'davidmh/cspell.nvim', version = false },
}

View File

@ -2,6 +2,7 @@
--
-- These are constant features of your window, plus any pop-in elements, like
-- vim.notify, vim.ui, or virtual text handlers
local keys = require 'psoxizsh.key.binds'
local logo = string.rep('\n', 8) .. [[
@ -56,8 +57,8 @@ return {
},
keys = function()
return {
{ '<TAB>' , '<cmd>BufferLineCycleNext<CR>' , desc = "Next Buffer" },
{ '<S-TAB>' , '<cmd>BufferLineCyclePrev<CR>' , desc = "Prev Buffer" },
keys.Global.BufferNext:as { 'lazy', action = '<cmd>BufferLineCycleNext<CR>' },
keys.Global.BufferPrev:as { 'lazy', action = '<cmd>BufferLineCyclePrev<CR>' },
}
end
},
@ -80,17 +81,15 @@ return {
-- vim.ui.input & vim.ui.select handler
{ 'stevearc/dressing.nvim',
name = 'dressing',
branch = 'master',
opts = {
input = {
default_prompt = '<|>',
mappings = { i = {
['<ESC>'] = 'Close',
['<CR>'] = 'Confirm',
['<Up>'] = 'HistoryPrev',
['<Down>'] = 'HistoryNext',
[keys.Plugin.Dressing.Close.Key] = 'Close',
[keys.Plugin.Dressing.Confirm.Key] = 'Confirm',
[keys.Plugin.Dressing.Prev.Key] = 'HistoryPrev',
[keys.Plugin.Dressing.Next.Key] = 'HistoryNext',
}},
},