summaryrefslogtreecommitdiff
path: root/fnl/conf/init.fnl
blob: 18b85618dc0b676a566151604328a0d3f2e6529c (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(vim.cmd "colorscheme kanagawa-wave")
(vim.cmd "filetype plugin on")
(vim.cmd "filetype indent on")
(vim.cmd "highlight WinSeparator guibg=None")
(vim.cmd "packadd cfilter")

(require :conf.settings)
(require :conf.pkgs)
(require :conf.lsp)
(require :conf.events)
(require :conf.filetype)
(require :conf.newtab)
(require :conf.nix-develop)

(require :conf.diagnostic)

;; TODO: make a function that sets this autocommand: au BufWritePost currentfile :!curl -X POST -d "{\"previewRun\": true, \"yamlOverride\": \"$(cat % | yq -P)\", \"resources\": {\"repositories\": {\"self\": {\"refName\": \"refs/heads/branch\"}}}}" -s -H "Content-Type: application/json" -H "Authorization: Basic $WORK_AZDO_GIT_AUTH" "$WORK_AZDO_GIT_ORG_URL/Stater/_apis/pipelines/pipelineid/preview?api-version=7.1-preview.1" | jq -r '.finalYaml // .' > scratch.yaml

(let [map vim.keymap.set]
  (map :t :<c-s> "<c-\\><c-n>")
  ;; pausing and continueing printing output is not necessary inside neovim terminal right?
  (map :t :<c-q> "<c-\\><c-n>:q<cr>")
  (map :n :<leader>qo ":copen<cr>")
  (map :n :<leader>qc ":cclose<cr>")
  (map :n :<leader>lo ":lopen<cr>")
  (map :n :<leader>lc ":lclose<cr>")
  (map :n "[q" ":cprevious<cr>")
  (map :n "]q" ":cnext<cr>")
  (map :n "[x" ":lprevious<cr>")
  (map :n "]x" ":lnext<cr>")
  (map :n :<c-p> ":Telescope find_files<cr>")
  (map :n "`<Backspace>" ":FocusDispatch ")
  (map :n :<leader>p ":NewTab<cr>")
  (map :n :<leader>cf ":tabedit ~/flake|tc ~/flake|G<cr><c-w>o")
  (map :n :<leader>cn ":tabedit ~/neovim|tc ~/neovim|G<cr><c-w>o"))

(tset _G :P (lambda [...]
              (let [inspected (icollect [_ v (ipairs [...])]
                                (vim.inspect v))]
                (each [_ printer (ipairs inspected)]
                  (print printer)))))

(vim.api.nvim_create_user_command :HomeManager
                                  (fn [ctx]
                                    (vim.cmd (.. ":Dispatch home-manager switch --impure "
                                                 (os.getenv :HOME) "/flake#"
                                                 (. ctx.fargs 1))))
                                  {:nargs 1})

(vim.api.nvim_create_user_command :Gpush
                                  (fn [ctx]
                                    (vim.cmd ":Dispatch git push"))
                                  {})

(vim.api.nvim_create_user_command :Grunt
                                  (fn [ctx]
                                    (match (. ctx.fargs 1)
                                      :plan (vim.cmd (.. ":Dispatch "
                                                         (if ctx.bang
                                                             "TF_LOG=DEBUG "
                                                             "")
                                                         "terragrunt "
                                                         (table.concat ctx.fargs
                                                                       " ")
                                                         " " :-out=gruntplan))
                                      :apply (vim.cmd (.. ":Dispatch "
                                                          (if ctx.bang
                                                              "TF_LOG=DEBUG "
                                                              "")
                                                          "terragrunt "
                                                          (table.concat ctx.fargs
                                                                        " ")
                                                          " " :gruntplan))
                                      _ (vim.cmd (.. ":Start "
                                                     (if ctx.bang
                                                         "TF_LOG=DEBUG "
                                                         "")
                                                     "terragrunt "
                                                     (table.concat ctx.fargs
                                                                   " ")))))
                                  {:nargs "*" :bang true})

(vim.api.nvim_create_user_command :K9s
                                  (fn [ctx]
                                    (vim.cmd (.. ":Start k9s --context "
                                                 (. ctx.fargs 1))))
                                  {:nargs 1})