repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim/lua/bugabinga/plugins/noice.lua.off

Raw
local map = require 'std.map'

return {
  {
    'folke/noice.nvim',
    event = 'VeryLazy',
    dependencies = {
      'MunifTanjim/nui.nvim',
      'rcarriga/nvim-notify',
    },
    opts = {
      -- cmdline = {
      --   view = 'cmdline', -- cmdline on cursor
      -- },
      lsp = {
        signature = {
          auto_open = { trigger = false },
        },
        -- override markdown rendering so that **cmp** and other plugins use **Treesitter**
        override = {
          ['vim.lsp.util.convert_input_to_markdown_lines'] = true,
          ['vim.lsp.util.stylize_markdown'] = true,
          ['cmp.entry.get_documentation'] = true,
        },
      },
      presets = {
        inc_rename = true,            -- enables an input dialog for inc-rename.nvim
        long_message_to_split = true, -- long messages will be sent to a split
      },
      views = {
        vsplit = {
          size = { width = 'auto', height = 'auto' },
        },
        popupmenu = {
          border = { style = vim.g.border_style },
        },
        popup = {
          border = { style = vim.g.border_style },
        },
        hover = {
          border = { style = vim.g.border_style },
          position = { row = -2, col = 2 },
        },
        cmdline = {
          relative = 'cursor',
          position = { row = 0, col = 2 },
          size = { width = '42', height = 'auto' },
          border = { style = 'solid' },
          zindex = 9999,
        },
        cmdline_popupmenu = {
          relative = 'cursor',
          position = { row = 1, col = 0 },
          size = { width = '42', height = 'auto' },
          border = { style = vim.g.border_style },
          zindex = 9999,
        },
      },
      routes = {
        {
          filter = { cmdline = '^:%s*!' },
          view = 'vsplit'
        },
        {
          filter = { event = 'msg_show', kind = 'echomsg' },
          view = 'mini'
        },
        {
          filter = { event = 'msg_show', kind = 'echo' },
          view   = 'mini'
        },
        {
          filter = { event = 'msg_show', kind = '', find = 'written' },
          view = 'mini'
        },
        {
          filter = { any = { { cmdline = '^:%s*lua%s+' }, { cmdline = '^:%s*lua%s*=%s*' }, { cmdline = '^:%s*=%s*' }, } },
          view = 'cmdline_output',
        }
      },
    },
    config = function ( _, opts )
      local noice = require 'noice'
      noice.setup( opts )

      map.normal {
        description = 'Open search for notifications...',
        category = 'search',
        keys = '<C-n><C-n>',
        command = function () noice.cmd 'history' end,
      }

      map.command_line {
        description = 'Redirect Cmdline',
        category = 'ui',
        keys = '<S-cr>',
        ---@diagnostic disable-next-line: param-type-mismatch
        command = function () noice.redirect( vim.fn.getcmdline() ) end,
      }

      map.normal {
        description = 'Dismiss current notifications',
        category = 'notify',
        keys = '<esc>',
        command = function () noice.cmd 'dismiss' end,
      }

      local noice_lsp = require 'noice.lsp'

      map.normal {
        description = 'Scroll up in documentation popup',
        category = 'ui',
        keys = '<C-f>',
        command = function ()
          if not noice_lsp.scroll( -4 ) then return '<C-f>' end
        end,
        options = { expr = true },
      }

      map.normal {
        description = 'Scroll down in documentation popup',
        category = 'ui',
        keys = '<C-b>',
        command = function ()
          if not noice_lsp.scroll( 4 ) then return '<C-b>' end
        end,
        options = { expr = true },
      }
    end,
  },
  {
    'rcarriga/nvim-notify',
    config = function ()
      local notify = require 'notify'
      local fade = require 'notify.stages.fade' 'bottom_up'

      local shadow_fade = function ( ... )
        local opts = fade[1]( ... )
        if opts then
          opts.border = vim.g.border_style
          opts.row = opts.row - 1
        end
        return opts
      end

      ---@diagnostic disable-next-line: missing-fields
      notify.setup {
        stages = { shadow_fade, unpack( fade, 2 ) },
        render = 'compact',
        timeout = 2500,
        fps = 60,
        top_down = false,
      }
    end,
  },
}