summaryrefslogtreecommitdiffstats
path: root/lua/conf/plugins/glance.lua
blob: c5a4d41b1c0c57389adb1d585c1f9fee46a899c7 (plain) (blame)
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
local misc = require('core.misc')
local map = misc.map

return { 'dnlhc/glance.nvim',
  disable = vim.version().minor < 7,
  function()
    require('glance').setup {
      border = {
        enable = true,
        top_char = '',
        bottom_char = '─',
      },
      folds = {
        fold_closed = '+',
        fold_open = '-',
        folded = true
      },
      theme = {
        enable = false
      },
      hooks = {
        before_open = function(results, open, jump, method)
          local uri = vim.uri_from_bufnr(0)
          if #results == 1 then
            local target_uri = results[1].uri or results[1].targetUri

            if target_uri == uri then
              jump()
              misc.timeout_highlight()
              return
            end
          end

          open()
        end
      }
    }

    map('n', 'gd', '<cmd>Glance definitions<CR>')
    map('n', 'gr', '<cmd>Glance references<CR>')
    map('n', 'gy', '<cmd>Glance type_definitions<CR>')
    map('n', 'gi', '<cmd>Glance implementations<CR>')
  end
}