summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/noice.lua
blob: 3648b55f78e51cf629e6bc358411595493c88937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
return {
    'folke/noice.nvim',
    event = 'VeryLazy',
    -- lazy = false,
    -- enabled = false,
    opts = {
        -- notify = { enabled = false },
        lsp = {
            progress = { enabled = false },
            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,
                -- override the lsp markdown formatter with Noice
                -- ['vim.lsp.util.stylize_markdown'] = true,
                -- ['cmp.entry.get_documentation'] = true,
            },
            hover = {
                ---@type NoiceViewOptions
                enabled = false,
                silent = false, -- set to true to not show a message if hover is not available
                view = nil, -- when nil, use defaults from documentation
                opts = {}, -- merged with defaults from documentation
            },
            signature = {
                -- NOTE: for some reason this makes the signature help prettier?
                -- not sure why noice does this, but might aswell use it
                enabled = true,
                auto_open = { enabled = false },
            },
            message = {
                -- Messages shown by lsp servers
                enabled = true,
                view = 'notify',
                opts = {},
            },
            -- defaults for hover and signature help
            documentation = {
                view = 'hover',
                --- @type NoiceViewOptions
                opts = {
                    lang = 'markdown',
                    replace = true,
                    render = 'plain',
                    -- render = function(buf, notif, hl, config)
                    --     self:render(buf, { offset = offset, highlight = true, messages = messages })
                    -- end,
                    format = { '{message}' },
                    win_options = { concealcursor = 'nvic', conceallevel = 3 },
                },
            },
        },
        messages = {
            enabled = true, -- enables the Noice messages UI
            view = 'notify', -- default view for messages
            view_error = 'messages', -- view for errors
            view_warn = 'notify', -- view for warnings
            view_history = 'messages', -- view for :messages
            view_search = false, -- view for search count messages. Set to `false` to disable
        },
        -- you can enable a preset for easier configuration
        cmdline = {
            enabled = true, -- enables the Noice cmdline UI
            view = 'cmdline_popup', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
            -- view = 'cmdline', -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom
            format = {
                cmdline = { pattern = '^:', icon = '', lang = 'vim' },
                search_down = { kind = 'search', pattern = '^/', icon = ' ', lang = 'regex' },
                search_up = { kind = 'search', pattern = '^%?', icon = ' ', lang = 'regex' },
                terminal = { pattern = '^:%s*!', icon = '$', lang = 'bash' },
                lua = { pattern = { '^:%s*lua%s+', '^:%s*lua%s*=%s*', '^:%s*=%s*' }, icon = '', lang = 'lua' },
                help = { pattern = '^:%s*he?l?p?%s+', icon = '' },
                input = { view = 'cmdline_input', icon = '󰥻 ' }, -- Used by input()
                -- lua = false, -- to disable a format, set to `false`
            },
            opts = {},
        },
        routes = {
            {
                -- NOTE: filters errors from the command line
                filter = {
                    event = 'msg_show',
                    error = true,
                    cmdline = true,
                },
                opts = { skip = true },
            },
            {
                -- NOTE: filters "fewer/more lines" messages
                filter = {
                    event = 'msg_show',
                    kind = '',
                    find = 'lines',
                },
                opts = { skip = true },
            },
            {
                -- NOTE: filters "pattern not found" messages
                filter = {
                    event = 'msg_show',
                    find = 'E486',
                },
                opts = { skip = true },
            },
        },
        presets = {
            bottom_search = true, -- use a classic bottom cmdline for search
            long_message_to_split = true, -- long messages will be sent to a split
            inc_rename = false, -- enables an input dialog for inc-rename.nvim
            lsp_doc_border = true, -- add a border to hover docs and signature help
        },
    },
    dependencies = {
        'MunifTanjim/nui.nvim',
        'rcarriga/nvim-notify',
    },
    config = function(_, opts)
        require('noice').setup(opts)
    end,
}