all repos

init.lua @ 6ad9f0d

my nvim config

init.lua/lua/core/utils.lua(view raw)

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
return {
  ---@param mode string|table
  ---@param from string
  ---@param to string|function
  ---@param buffer? integer|boolean
  map = function(mode, from, to, buffer)
    vim.keymap.set(mode, from, to, {
      noremap = true,
      silent = true,
      buffer = buffer or false,
    })
  end,

  aucmd = vim.api.nvim_create_autocmd,

  ---@param name string
  ---@return integer
  augroup = function(name)
    return vim.api.nvim_create_augroup("olexsmir_" .. name, { clear = true })
  end,

  lsp = {
    ---@param extend? table
    capabilities = function(extend)
      return require("blink.cmp").get_lsp_capabilities(extend or {})
    end,

    ---@param bufnr integer
    ---@param name string
    ---@param command lsp.ExecuteCommandParams
    command = function(bufnr, name, command)
      vim.api.nvim_buf_create_user_command(bufnr, name, function()
        vim.lsp.buf.execute_command(command)
      end, {})
    end,

    ---get list of lsp servers connected to current buffer
    ---@return string[]
    get_clients = function()
      return vim
        .iter(vim.lsp.get_clients { bufnr = 0 })
        :map(function(e)
          return (e.name ~= "null-ls" and e.name) or nil
        end)
        :totable()
    end,
  },
}