feat(nvim): accept completion suggestion with TAB

This commit is contained in:
2026-05-06 21:20:17 -04:00
parent 224eb3d645
commit 712c4c61ff
2 changed files with 79 additions and 2 deletions

View File

@@ -218,6 +218,8 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' }) vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
require('custom.dotnet').setup()
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" }) -- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" }) -- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
@@ -865,7 +867,7 @@ require('lazy').setup({
-- <c-y> to accept ([y]es) the completion. -- <c-y> to accept ([y]es) the completion.
-- This will auto-import if your LSP supports it. -- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet. -- This will expand snippets if the LSP sent a snippet.
-- 'super-tab' for tab to accept -- 'super-tab' for tab to accept, with Up/Down selecting suggestions.
-- 'enter' for enter to accept -- 'enter' for enter to accept
-- 'none' for no mappings -- 'none' for no mappings
-- --
@@ -882,7 +884,7 @@ require('lazy').setup({
-- <c-k>: Toggle signature help -- <c-k>: Toggle signature help
-- --
-- See :h blink-cmp-config-keymap for defining your own keymap -- See :h blink-cmp-config-keymap for defining your own keymap
preset = 'default', preset = 'super-tab',
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps

View File

@@ -0,0 +1,75 @@
local M = {}
local dotnet_errorformat = {
[[%f(%l\,%c): %trror %m]],
[[%f(%l\,%c): %tarning %m]],
[[%f(%l): %trror %m]],
[[%f(%l): %tarning %m]],
[[%f : %trror %m]],
[[%f : %tarning %m]],
[[%-G%.%#]],
}
function M.configure_buffer()
vim.opt_local.makeprg = 'dotnet build'
vim.opt_local.errorformat = dotnet_errorformat
end
function M.build(args)
M.configure_buffer()
local command = 'silent make!'
if args and args ~= '' then
command = command .. ' ' .. args
end
vim.cmd(command)
vim.cmd.cwindow()
local count = #vim.fn.getqflist()
if count == 0 then
vim.notify('dotnet build finished without quickfix entries', vim.log.levels.INFO)
else
vim.notify(('dotnet build populated %d quickfix item%s'):format(count, count == 1 and '' or 's'), vim.log.levels.INFO)
end
end
function M.setup()
local group = vim.api.nvim_create_augroup('custom-dotnet', { clear = true })
vim.api.nvim_create_autocmd('FileType', {
group = group,
pattern = { 'cs', 'fsharp', 'vb' },
callback = M.configure_buffer,
})
vim.api.nvim_create_autocmd({ 'BufReadPost', 'BufNewFile' }, {
group = group,
pattern = { '*.csproj', '*.fsproj', '*.vbproj', '*.sln', '*.slnx', '*.props', '*.targets' },
callback = M.configure_buffer,
})
vim.api.nvim_create_user_command('DotnetBuild', function(opts)
M.build(opts.args)
end, {
nargs = '*',
complete = 'file',
desc = 'Build the current .NET solution/project into the quickfix list',
})
vim.keymap.set('n', '<leader>mb', '<cmd>DotnetBuild<CR>', { desc = '[M]ake dotnet [B]uild' })
vim.keymap.set('n', '<leader>mq', '<cmd>copen<CR>', { desc = '[M]ake: Open [Q]uickfix' })
vim.keymap.set('n', '<leader>mc', '<cmd>cclose<CR>', { desc = '[M]ake: [C]lose quickfix' })
vim.keymap.set('n', ']q', '<cmd>cnext<CR>zz', { desc = 'Next quickfix item' })
vim.keymap.set('n', '[q', '<cmd>cprevious<CR>zz', { desc = 'Previous quickfix item' })
vim.api.nvim_create_autocmd('FileType', {
group = group,
pattern = 'qf',
callback = function(event)
vim.keymap.set('n', 'q', '<cmd>cclose<CR>', { buffer = event.buf, desc = 'Close quickfix' })
end,
})
end
return M