nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

functions.fnl (4071B)


      1 (vim.api.nvim_create_user_command :Lsp
      2                                   (fn [opts]
      3                                     (vim.lsp.enable opts.fargs)
      4                                     (vim.api.nvim_exec_autocmds :FileType
      5                                                                 {:group :nvim.lsp.enable
      6                                                                  :buffer 0}))
      7                                   {:nargs "+"
      8                                    :complete #(icollect [_ path (ipairs (vim.api.nvim_get_runtime_file :lsp/*.lua
      9                                                                                                        true))]
     10                                                 (vim.fn.fnamemodify path ":t:r"))})
     11 
     12 (vim.api.nvim_create_autocmd [:BufRead :BufNewFile]
     13                              {:pattern [:*.m3u :*.m3u8]
     14                               :callback (fn []
     15                                           (set vim.bo.filetype :text)
     16                                           (set vim.bo.syntax :text))})
     17 
     18 (let [group (vim.api.nvim_create_augroup :MagdalenaLogFile {:clear true})]
     19   (vim.api.nvim_create_autocmd [:BufReadPost :BufNewFile]
     20                                {: group
     21                                 :callback (fn [ev]
     22                                             (let [filename (vim.api.nvim_buf_get_name ev.buf)]
     23                                               (when (and filename
     24                                                          (not= filename "")
     25                                                          (not (filename:match "^oil://")))
     26                                                 (let [_job (vim.fn.jobstart [:magdalena
     27                                                                              :log-file
     28                                                                              filename]
     29                                                                             {:detach true
     30                                                                              :on_stderr (fn [_
     31                                                                                              _])
     32                                                                              :on_exit (fn [_
     33                                                                                            _])})]
     34                                                   nil))))}))
     35 
     36 (vim.api.nvim_create_autocmd :FileType
     37                              {:pattern :markdown
     38                               :callback (fn []
     39                                           (set vim.opt_local.suffixesadd :.md)
     40                                           (set vim.opt_local.includeexpr
     41                                                "v:lua.follow_md_link()")
     42                                           (global follow_md_link
     43                                                   #(: vim.v.fname :gsub
     44                                                       "%[%[(.-)%]%]" "%1"))
     45                                           (vim.keymap.set :n :gf
     46                                                           (fn []
     47                                                             (let [line (vim.api.nvim_get_current_line)
     48                                                                   col (. (vim.api.nvim_win_get_cursor 0)
     49                                                                          2)
     50                                                                   link (line:match "%[([%w_%-][%w_%-]+)%]"
     51                                                                                    col)]
     52                                                               (if link
     53                                                                   (vim.cmd (.. "edit "
     54                                                                                link
     55                                                                                :.md))
     56                                                                   (vim.cmd "normal! gf"))))
     57                                                           {:buffer true}))})