From f13a62d3fd2884865398627d8a168e0c7df82ff4 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sat, 3 May 2025 16:07:54 +0300 Subject: [PATCH] Changed some nvim stuff, giving a try to terminals again, added keybinds to easily open/close the terminal and also Ctrl+HJKL to navigate --- .config/nvim/lua/plugins/noice.lua | 10 +++---- .config/nvim/lua/plugins/octo.lua | 36 +++++++++++++----------- .config/nvim/lua/plugins/snacks.lua | 43 +++++++++++++++++++++-------- 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/.config/nvim/lua/plugins/noice.lua b/.config/nvim/lua/plugins/noice.lua index 1420ab5..06de5a5 100644 --- a/.config/nvim/lua/plugins/noice.lua +++ b/.config/nvim/lua/plugins/noice.lua @@ -5,20 +5,18 @@ return { notify = { enabled = false }, lsp = { progress = { enabled = false }, - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** override = { + -- override markdown rendering so that **cmp** and other plugins use **Treesitter** -- override the default lsp markdown formatter with Noice - ['vim.lsp.util.convert_input_to_markdown_lines'] = true, + -- ['vim.lsp.util.convert_input_to_markdown_lines'] = true, -- override the lsp markdown formatter with Noice - ['vim.lsp.util.stylize_markdown'] = true, - -- override cmp documentation with Noice (needs the other options to work) - -- ['cmp.entry.get_documentation'] = true, -- requires hrsh7th/nvim-cmp + -- ['vim.lsp.util.stylize_markdown'] = true, }, hover = { + ---@type NoiceViewOptions enabled = true, silent = false, -- set to true to not show a message if hover is not available view = nil, -- when nil, use defaults from documentation - ---@type NoiceViewOptions opts = {}, -- merged with defaults from documentation }, signature = { diff --git a/.config/nvim/lua/plugins/octo.lua b/.config/nvim/lua/plugins/octo.lua index 96120af..ccb518d 100644 --- a/.config/nvim/lua/plugins/octo.lua +++ b/.config/nvim/lua/plugins/octo.lua @@ -1,6 +1,7 @@ return { 'pwntester/octo.nvim', cmd = 'Octo', + event = { { event = 'BufReadCmd', pattern = 'octo://*' } }, dependencies = { 'nvim-lua/plenary.nvim', 'folke/snacks.nvim', @@ -11,21 +12,24 @@ return { { 'pr', 'Octo pr search', desc = 'Github [PR]s (local)' }, { 'gI', 'Octo search is:issue is:open author:@me', desc = '[G]ithub [I]ssues (global)' }, { 'pR', 'Octo search is:pr author:@me', desc = 'Github [PR]s (global)' }, - }, - config = function() - require('octo').setup({ - suppress_missing_scope = { projects_v2 = true }, - picker = 'snacks', - }) - vim.treesitter.language.register('markdown', 'octo') - vim.api.nvim_create_autocmd('FileType', { - pattern = 'octo', - callback = function() - -- Autocomplete for @ (user mention) and # (issue) - vim.keymap.set('i', '@', '@', { silent = true, buffer = true }) - vim.keymap.set('i', '#', '#', { silent = true, buffer = true }) - end, - }) - end, + { 'a', '', desc = '+assignee (Octo)', ft = 'octo' }, + { 'c', '', desc = '+comment/code (Octo)', ft = 'octo' }, + { 'l', '', desc = '+label (Octo)', ft = 'octo' }, + { 'i', '', desc = '+issue (Octo)', ft = 'octo' }, + { 'r', '', desc = '+react (Octo)', ft = 'octo' }, + { 'p', '', desc = '+pr (Octo)', ft = 'octo' }, + { 'pr', '', desc = '+rebase (Octo)', ft = 'octo' }, + { 'ps', '', desc = '+squash (Octo)', ft = 'octo' }, + { 'v', '', desc = '+review (Octo)', ft = 'octo' }, + { 'g', '', desc = '+goto_issue (Octo)', ft = 'octo' }, + { '@', '', mode = 'i', ft = 'octo', silent = true }, + { '#', '', mode = 'i', ft = 'octo', silent = true }, + }, + opts = { + enable_builtin = true, + -- default_to_projects_v2 = true, + default_merge_method = 'squash', + picker = 'snacks', + }, } diff --git a/.config/nvim/lua/plugins/snacks.lua b/.config/nvim/lua/plugins/snacks.lua index 85714b9..7fa7238 100644 --- a/.config/nvim/lua/plugins/snacks.lua +++ b/.config/nvim/lua/plugins/snacks.lua @@ -1,3 +1,13 @@ +local function term_nav(dir) + ---@param self snacks.terminal + return function(self) + return self:is_floating() and '' + or vim.schedule(function() + vim.cmd.wincmd(dir) + end) + end +end + return { 'folke/snacks.nvim', priority = 1000, @@ -21,7 +31,14 @@ return { style = 'compact', filter = function(notif) local exact_filter = { 'No information available', 'No code actions available' } - local contains_filter = { 'fewer lines', 'lines indented', 'lines yanked', 'more lines', 'E486:' } + local contains_filter = { + 'fewer lines', + 'lines indented', + 'lines yanked', + 'more lines', + 'lines moved', + 'E486:', + } for _, msg in ipairs(exact_filter) do if notif.msg == msg then return false @@ -67,7 +84,16 @@ return { -- easing = 'linear', -- }, -- }, - terminal = {}, + terminal = { + win = { + keys = { + nav_h = { '', term_nav('h'), desc = 'Go to Left Window', expr = true, mode = 't' }, + nav_j = { '', term_nav('j'), desc = 'Go to Lower Window', expr = true, mode = 't' }, + nav_k = { '', term_nav('k'), desc = 'Go to Upper Window', expr = true, mode = 't' }, + nav_l = { '', term_nav('l'), desc = 'Go to Right Window', expr = true, mode = 't' }, + }, + }, + }, }, keys = { { @@ -107,7 +133,7 @@ return { { 'nh', function() - Snacks.notifier.show_history() + Snacks.picker.notifications({ layout = 'telescope' }) end, desc = '[N]otification [H]istory', }, @@ -247,18 +273,11 @@ return { }, { - 'nt', + '', function() - Snacks.terminal.open() + Snacks.terminal() end, desc = '[N]ew [T]erminal', }, - { - 'T', - function() - Snacks.terminal.toggle() - end, - desc = 'Toggle [T]erminal', - }, }, }