~sanchayanmaity/dotfiles

ref: 918df6307351be6d7b6f40a9de4b415cf6b19f00 dotfiles/nvim/.config/nvim/lua/autocmd.lua -rw-r--r-- 1.1 KiB
918df630Sanchayan Maity nvim: Fix group argument to nvim_create_autocmd 3 months ago
                                                                                
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
local custom_augroup_id = vim.api.nvim_create_augroup("custom_group", {clear = true})

local aucmd_dict = {
  TermOpen = {
    {
      group   = custom_augroup_id,
      pattern = "*",
      command = "startinsert"
    },
    {
      group   = custom_augroup_id,
      pattern = "*",
      command = "setlocal listchars= nonumber norelativenumber"
    },
  },
  VimResized = {
    {
      group   = custom_augroup_id,
      pattern = "*",
      command = ":wincmd ="
    }
  },
  InsertEnter = {
    {
      group   = custom_augroup_id,
      pattern = "*",
      command = "setlocal nohlsearch"
    }
  },
  TextYankPost = {
    {
      group   = custom_augroup_id,
      pattern = "*",
      callback = function ()
        require("vim.highlight").on_yank({timeout = 1000})
      end,
    }
  },
  VimLeave = {
    {
      group   = custom_augroup_id,
      pattern = "*",
      command = "set guicursor=a:hor1-blinkon0"
    }
  }
}

for event, opt_tbls in pairs(aucmd_dict) do
  for _, opt_tbl in pairs(opt_tbls) do
    vim.api.nvim_create_autocmd(event, opt_tbl)
  end
end