dot

NixOS dotfiles
git clone https://git.echoz.io/dot.git
Log | Files | Refs

cheat-sheet.nix (1034B)


      1 {
      2   programs.neovim.customPlugins.cheat-sheet = {
      3     "plugin/cheat-sheet.lua" = # lua
      4       ''
      5         local file = '${../cheat-sheet.txt}'
      6         local lines = {}
      7 
      8         for line in io.lines(file) do
      9           table.insert(lines, line)
     10         end
     11 
     12         vim.keymap.set({'n','v'}, '<C-/>', function()
     13           local buf = vim.api.nvim_create_buf(false, true)
     14           vim.api.nvim_buf_set_keymap(buf, 'n', 'q', ':q<CR>', {
     15             silent = true,
     16             nowait = true,
     17           })
     18           vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
     19           local win = vim.api.nvim_open_win(buf, true, {
     20             title = 'Cheat sheet',
     21             relative = 'editor',
     22             row = math.floor(vim.o.lines * 0.10),
     23             col = math.floor(vim.o.columns * 0.10),
     24             height = math.floor(vim.o.lines * 0.80),
     25             width = math.floor(vim.o.columns * 0.80),
     26             style = 'minimal',
     27             title_pos = 'center',
     28             focusable = true,
     29           })
     30         end)
     31       '';
     32   };
     33 }