diff options
| author | Mike Vink <mike1994vink@gmail.com> | 2022-11-25 23:31:42 +0100 |
|---|---|---|
| committer | Mike Vink <mike1994vink@gmail.com> | 2022-11-25 23:31:42 +0100 |
| commit | 84e66a22a3dcbf51afcefdcd065d1f1c6a0fd95f (patch) | |
| tree | 20721abe8e9fe3209e724119230e62581f3287a6 | |
| parent | 532d58f386f6b7c35ef1d6404659e9f1508414bf (diff) | |
move options
| -rw-r--r-- | neovim/fnl/conf/init.fnl | 3 | ||||
| -rw-r--r-- | neovim/fnl/conf/log.fnl | 53 | ||||
| -rw-r--r-- | neovim/fnl/conf/macros.fnl | 102 | ||||
| -rw-r--r-- | neovim/fnl/conf/settings.fnl | 63 | ||||
| -rw-r--r-- | neovim/oldinit.lua | 93 |
5 files changed, 136 insertions, 178 deletions
diff --git a/neovim/fnl/conf/init.fnl b/neovim/fnl/conf/init.fnl index 217614f..2888e0b 100644 --- a/neovim/fnl/conf/init.fnl +++ b/neovim/fnl/conf/init.fnl @@ -1,5 +1,3 @@ -(import-macros {: P} :conf.macros) - (tset (. vim "g") "mapleader" " ") (tset (. vim "g") "maplocalleader" " ") @@ -11,3 +9,4 @@ (require :conf.lsp) (require :conf.pkgs) +(require :conf.settings) diff --git a/neovim/fnl/conf/log.fnl b/neovim/fnl/conf/log.fnl index 4507518..cf859f2 100644 --- a/neovim/fnl/conf/log.fnl +++ b/neovim/fnl/conf/log.fnl @@ -2,27 +2,38 @@ (local scratches {}) (fn scratch-buffer [name ft] - (fn setopt [buf opt value] - (vim.api.nvim_buf_set_option buf opt value) buf) - (fn track [buf] (tset scratches name buf) buf + (fn setopt [buf opt value] + (vim.api.nvim_buf_set_option buf opt value) + buf) - (track (-> (vim.api.nvim_create_buf true false) - (setopt :filetype ft) - (setopt :buftype :nofile) - (setopt :bufhidden :hide) - (setopt :swapfile false))))) + (fn track [buf] + (tset scratches name buf) + buf) -(let [log (fn [...] (P [...]))] - (vim.api.nvim_create_user_command - :Scratch - (fn [c] - (let [name c.args] - (fn exists? [buf] (not= buf nil)) - (fn get [] (. scratches c.args)) - (fn goto [buf] - (vim.api.nvim_set_current_buf buf)) + (track (-> (vim.api.nvim_create_buf true false) + (setopt :filetype ft) + (setopt :buftype :nofile) + (setopt :bufhidden :hide) + (setopt :swapfile false)))) - (let [buf (get) current (vim.api.nvim_get_current_buf)] - (if (exists? buf) (goto buf) (goto (scratch-buffer name (vim.api.nvim_buf_get_option current :filetype))))))) - {:complete log - :nargs 1})) +(let [log (fn [...] + (P [...]))] + (vim.api.nvim_create_user_command :Scratch + (fn [c] + (let [name c.args] + (fn exists? [buf] + (not= buf nil)) + + (fn get [] + (. scratches c.args)) + + (fn goto [buf] + (vim.api.nvim_set_current_buf buf)) + + (let [buf (get) + current (vim.api.nvim_get_current_buf)] + (if (exists? buf) (goto buf) + (goto (scratch-buffer name + (vim.api.nvim_buf_get_option current + :filetype))))))) + {:complete log :nargs 1})) diff --git a/neovim/fnl/conf/macros.fnl b/neovim/fnl/conf/macros.fnl index ff08329..04a7251 100644 --- a/neovim/fnl/conf/macros.fnl +++ b/neovim/fnl/conf/macros.fnl @@ -1,62 +1,48 @@ -;; cannot be at the bottom? +(fn by-two [l] + (fn iter [t i] + (let [k (. l (- i 1)) + v (. l i)] + (when (and (not= k nil) (not= v nil)) + (values (+ i 2) [k v])))) + + (values iter l 2)) + +(fn decode-opt-value [v] + (fn symbol-luatype [s] + (let [t (tostring s)] + (match t + :on true + :off false + _ t))) + + (if (sym? v) (symbol-luatype v) v)) + +(fn opt-template [o] + (fn remove/append [target value mode] + `(let [target# (. vim :opt ,target) + value# ,value] + ,(match mode + :append `(target#:append value#) + :remove `(target#:remove value#)))) + + (fn [v] + (match (string.sub o 1 1) + "-" (remove/append (string.sub o 2) v :remove) + "+" (remove/append (string.sub o 2) v :append) + _ `(tset (. vim :opt) ,o ,v)))) (fn settings [...] - (fn stringify [l] - (icollect [_ v (ipairs l)] - (tostring v))) - - (fn ->tbl [l] - (local tbl {}) - - (fn iter [i] - (let [k (. l (- i 1)) - v (. l i)] - (when (and k v) - (tset tbl k v) - (iter (+ i 2))))) - - (iter 2) - tbl) - - (fn value-type [v] - (match v - :on true - :no false - v v)) - - (fn template [k v method] - `(let [s# (. vim :opt ,k) - t# ,(value-type v)] - ,(match method - :append `(s#:append t#) - :remove `(s#:remove t#) - :set `(tset (. vim :opt) ,k t#)))) - - (fn transform [tbl] - (icollect [k v (pairs tbl)] - (match (string.sub k 1 1) - "+" (template (string.sub k 2) v :append) - "-" (template (string.sub k 2) v :remove) - _ (template k v :set)))) - - (let [l (-> [...] - (stringify) - (->tbl) - (transform))] - `,l)) - -(fn globals [...]) - -;; (let [opts-tbl (-> [...] -;; (stringify) -;; (->tbl {}))] -;; `(each [k# v# (pairs ,opts-tbl)] -;; (match [k# v#] -;; [a# :true] (tset (. vim :opt) k# true) -;; [a# :false] (tset (. vim :opt) k# false) -;; [a# b#] (tset (. vim :opt) k# v#))))) - -(fn P [p] - `(print (vim.inspect ,p))) + `,(icollect [_ [o v] (by-two [...])] + ((opt-template (tostring o)) (decode-opt-value v)))) + +(fn globals [...] + (local globa (icollect [_ [k v] (by-two [...])] + [(tostring k) v])) + `(let [l# ,globa] + (each [a# b# (ipairs l#)] + (tset (. vim :g) (. b# 1) (. b# 2))))) + +(fn P [...] + `(print (vim.inspect [...]))) {: P : settings : globals} diff --git a/neovim/fnl/conf/settings.fnl b/neovim/fnl/conf/settings.fnl index 7f22d82..f7c0d88 100644 --- a/neovim/fnl/conf/settings.fnl +++ b/neovim/fnl/conf/settings.fnl @@ -1,5 +1,60 @@ -(import-macros { : settings} :conf.macros) +(import-macros {: settings : globals} :conf.macros) + +(globals + loaded_2html_plugin true + loaded_fzf false + loaded_man false + loaded_gzip false + loaded_health false + loaded_matchit false + loaded_matchparen false + loaded_netrwPlugin false + loaded_rplugin false + loaded_shada false + loaded_spellfile false + loaded_tarPlugin false + loaded_tohtml false + loaded_tutor false + loaded_zipPlugin false + + dirvish_mode ":sort | sort ,^.*[^/]$, r") + (settings - backup false - backupcopy yes - foldmarker "///,///") + +shortmess "c" + +diffopt vertical + +isfname "@-@" + wmw 10 + inccommand split + signcolumn yes + smd off + scrolloff 8 + termguicolors on + incsearch on + undofile on + undodir (.. (os.getenv :HOME) :/.local/share/nvim/undo) + backup off + swapfile off + wrap off + splitbelow on + magic on + showbreak "" + listchars { :tab " " :eol ""} + list on + autoindent on + smartindent on + expandtab on + tabstop 4 + softtabstop 4 + shiftwidth 4 + hidden on + number on + relativenumber on + exrc on + secure on + completeopt "menuone,noselect" + complete ".,w,k,kspell,b" + foldopen "block,hor,jump,mark,percent,quickfix,search,tag" + laststatus 3 + winbar "%=%m %f" + hlsearch off + clipboard "") diff --git a/neovim/oldinit.lua b/neovim/oldinit.lua index 1c151f6..af8eb1f 100644 --- a/neovim/oldinit.lua +++ b/neovim/oldinit.lua @@ -114,104 +114,11 @@ augroup end end cwd_save_session() - - - --- general options {{{ -vim.opt.clipboard = {} -vim.api.nvim_set_keymap( - "n", - "s", - "<Plug>Ysurround", - {silent=true,noremap=true} -) - --- don't load standard plugins - -vim.g.loaded_2html_plugin = false -vim.g.loaded_fzf = false -vim.g.loaded_man = false -vim.g.loaded_gzip = false -vim.g.loaded_health = false -vim.g.loaded_matchit = false -vim.g.loaded_matchparen = false -vim.g.loaded_netrwPlugin = false -vim.g.loaded_rplugin = false -vim.g.loaded_shada = false -vim.g.loaded_spellfile = false -vim.g.loaded_tarPlugin = false -vim.g.loaded_tohtml = false -vim.g.loaded_tutor = false -vim.g.loaded_zipPlugin = false - vim.cmd [[filetype plugin on]] vim.cmd [[filetype indent on]] vim.cmd [[colorscheme gruvbox-material]] vim.cmd [[highlight WinSeparator guibg=None]] -vim.opt.laststatus = 3 -vim.opt.winbar = "%=%m %f" - - -vim.g.dirvish_mode = ':sort | sort ,^.*[^/]$, r' - -vim.opt.foldopen = "block,hor,jump,mark,percent,quickfix,search,tag" -vim.opt.complete = ".,w,k,kspell,b" -vim.opt.completeopt = "menuone,noselect" - - -vim.opt.secure = true -vim.opt.exrc = true - --- relativenumbers and absolute number -vim.opt.relativenumber = true -vim.opt.number = true - --- don't show previous search pattern -vim.opt.hlsearch = false - --- don't free buffer memory when abandoned -vim.opt.hidden = true - --- 1 tab == 4 spaces -vim.opt.tabstop = 4 -vim.opt.softtabstop = 4 -vim.opt.shiftwidth = 4 - --- use spaces instead of tabs -vim.opt.expandtab = true - -vim.opt.smartindent = true -vim.opt.autoindent = true - --- show special characters as listed -vim.opt.list = true -vim.opt.listchars = { tab = ' ', eol = "" } -vim.opt.showbreak = '' - --- make pasting better but makes insert mappings stop working... --- vim.opt.paste = true - --- magic vim patterns -vim.opt.magic = true - --- make splitting consistent -vim.opt.splitbelow = true -vim.opt.wrap = false -vim.opt.swapfile = false -vim.opt.backup = false -vim.opt.undodir = os.getenv('HOME') .. "/.local/share/nvim/undo" -vim.opt.undofile = true -vim.opt.incsearch = true -vim.opt.termguicolors = true -vim.opt.scrolloff = 8 -vim.opt.smd = false -vim.opt.signcolumn = "yes" -vim.opt.inccommand = "split" -vim.opt.wmw = 10 -vim.opt.isfname:append("@-@") -vim.opt.diffopt:append("vertical") -vim.opt.shortmess:append("c") -- }}} |
