summary refs log tree commit diff
path: root/.vim/lua
diff options
context:
space:
mode:
Diffstat (limited to '.vim/lua')
-rw-r--r--.vim/lua/internal/lsp_symbols.lua36
-rw-r--r--.vim/lua/internal/notify.lua105
2 files changed, 141 insertions, 0 deletions
diff --git a/.vim/lua/internal/lsp_symbols.lua b/.vim/lua/internal/lsp_symbols.lua
new file mode 100644
index 0000000..ce8b1a7
--- /dev/null
+++ b/.vim/lua/internal/lsp_symbols.lua
@@ -0,0 +1,36 @@
+return {
+  -- 󰆼  󱆃
+  Array = '󰨾 ',
+  Boolean = '󰦍 ',
+  Class = '󰙀 ',
+  Color = '󰉦 ',
+  Constant = ' ',
+  Constructor = '󱇿 ',
+  Enum = ' ',
+  EnumMember = ' ',
+  Event = '󱐋 ',
+  -- Field = '󰽜 ',
+  Field = '󰆈 ',
+  File = '󰈔 ',
+  Folder = '󰝰 ',
+  Function = ' ',
+  Interface = '󱦜 ',
+  Key = '󰌋 ',
+  Keyword = '󰓽 ',
+  Method = '󰒓 ',
+  Module = '󰏖 ',
+  Namespace = '󰆧 ',
+  Null = '󰎣 ',
+  Object = '󰘦 ',
+  Operator = '󱓉 ',
+  Property = '󰐱 ',
+  Package = '󰏗 ',
+  Reference = '󰌹 ',
+  Snippet = '󰯁 ',
+  Struct = '󰙅 ',
+  Text = '󰉿 ',
+  TypeParameter = '󰌨 ',
+  Unit = '󰠱 ',
+  Value = '󰎠 ',
+  Variable = '󱄑 ',
+}
diff --git a/.vim/lua/internal/notify.lua b/.vim/lua/internal/notify.lua
new file mode 100644
index 0000000..5445f4f
--- /dev/null
+++ b/.vim/lua/internal/notify.lua
@@ -0,0 +1,105 @@
+-- notifications cache
+_G.statusline_notifications = {}
+_G.statusline_notifications_archive = {}
+
+-- out vim.notify implementation
+local notify = function(m, l, o)
+  local lvl_string = l
+  local hi = nil
+  if l and type(l) == 'number' then
+    if l == vim.log.levels.TRACE then
+      hi = 'deEmph'
+    elseif l == vim.log.levels.DEBUG then
+      hi = 'DiagnosticHint'
+    elseif l == vim.log.levels.INFO then
+      hi = 'DiagnosticInfo'
+    elseif l == vim.log.levels.WARN then
+      hi = 'DiagnosticWarn'
+    elseif l == vim.log.levels.ERROR then
+      hi = 'DiagnosticError'
+    end
+    -- get level string
+    lvl_string = vim.lsp.log_levels[l]
+  end
+  local display = m
+  if lvl_string then
+    display = lvl_string .. ' ' .. display
+  end
+  table.insert(_G.statusline_notifications, {
+    message = m,
+    level = l,
+    options = o,
+    lvl_string = lvl_string,
+    hi = hi,
+    display = display,
+  })
+
+  if _G.statusline_enable_notifysend then
+    local args = {}
+    if lvl_string then
+      if lvl_string == 'ERROR' then
+        table.insert(args, '--category=error')
+      end
+      if lvl_string == 'WARN' then
+        table.insert(args, '--category=warning')
+      end
+    end
+    table.insert(args, 'nvim')
+    table.insert(args, display)
+    require('internal.job').jobstart({ command = 'notify-send', args = args })
+  end
+end
+
+-- overwrite vim.notify
+vim.notify = function(m, l, o)
+  if vim.in_fast_event() then
+    vim.schedule(function()
+      notify(m, l, o)
+    end)
+  else
+    return notify(m, l, o)
+  end
+end
+
+vim.keymap.set('n', '<leader>n', function()
+  local pickers = require('telescope.pickers')
+  local finders = require('telescope.finders')
+  local conf = require('telescope.config').values
+  local actions = require('telescope.actions')
+  -- local action_state = require('telescope.actions.state')
+  -- local previewers = require('telescope.previewers')
+
+  local opts = {}
+  pickers
+    .new(opts, {
+      prompt_title = 'Notifications',
+      finder = finders.new_dynamic({
+        fn = function()
+          return _G.statusline_notifications_archive
+        end,
+        entry_maker = function(n)
+          return {
+            value = n,
+            display = n.display,
+            ordinal = n.message,
+          }
+        end,
+      }),
+      sorter = conf.generic_sorter(opts),
+      attach_mappings = function(prompt_bufnr, _)
+        actions.select_default:replace(function()
+          actions.close(prompt_bufnr)
+          -- noop
+          -- local sel = action_state.get_selected_entry()
+          -- vim.notify(sel.value.message, sel.value.level, sel.value.options)
+        end)
+        return true
+      end,
+      -- previewer = previewers.new_buffer_previewer {
+      --   define_preview = function(self, entry)
+      --     vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, {entry.value.display})
+      --   end,
+      -- },
+    })
+    :find()
+end, { desc = 'notifications' })