summaryrefslogtreecommitdiff
path: root/dot_config/nvim/pre.fnl
blob: a22a233bd234c9d585829c167deb61097f2b478b (plain) (blame)
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
(import-macros {: recc} :toast.macros)

(set vim.g.mapleader " ")
(set vim.g.maplocalleader "\\")

(local options {:timeoutlen 300
                :clipboard :unnamedplus
                :completeopt "menu,menuone,noselect"
                :mouse :a
                :smartcase true
                :smartindent true
                :backup false
                :swapfile false
                :termguicolors true
                :expandtab false
                :shiftwidth 4
                :tabstop 4
                :number true
                :numberwidth 2
                :scrolloff 4
                :sidescrolloff 4
                :foldmethod :expr
                :foldexpr "nvim_treesitter#foldexpr()"
                :foldlevelstart 99
                :wrap true})

(each [k v (pairs options)]
  (tset vim.opt k v))

; OSC 52 on nvim >= 0.10.0
(let [{: major : minor} (vim.version)]
 (when (or (> major 0) (>= minor 10))
  (set vim.g.clipboard {:name :OSC52
                        :copy  {:+ (recc :vim.ui.clipboard.osc52 :copy  :+)
                                :* (recc :vim.ui.clipboard.osc52 :copy  :*)}
                        :paste {:+ (recc :vim.ui.clipboard.osc52 :paste :+)
                                :* (recc :vim.ui.clipboard.osc52 :paste :*)}})))

; editorconfig extensions
(let [ec (require :editorconfig)]
  (set ec.properties.filetype
       (fn [bufnr val opts]
         (let [bo (. vim.bo bufnr)]
           (when (not= bo.filetype val)
             (set bo.filetype val)
             ; otherwise the change in ft will override editorconfig settings
             (ec.config bufnr))))))