From 27bdad73f556e309ef7426d8c2f875088b9772a9 Mon Sep 17 00:00:00 2001 From: amelia squires Date: Mon, 2 Dec 2024 15:00:06 -0600 Subject: lots of stuff + work on settings ui --- fnl/defaults.fnl | 1 + fnl/layouts/ide.fnl | 4 ++++ fnl/layouts/quiet.fnl | 4 ++++ fnl/opt.fnl | 15 ++++++++---- fnl/plugins/which_key.fnl | 7 +++--- fnl/settings-ui.fnl | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 fnl/layouts/ide.fnl create mode 100644 fnl/layouts/quiet.fnl create mode 100644 fnl/settings-ui.fnl (limited to 'fnl') diff --git a/fnl/defaults.fnl b/fnl/defaults.fnl index c50c4e4..71dac80 100644 --- a/fnl/defaults.fnl +++ b/fnl/defaults.fnl @@ -2,6 +2,7 @@ (when (or (= (. _G.settings key) nil) ?force) (tset _G.settings key value))) (global defaults (lambda [force] + (default :layout "" force) (default :colorscheme :oxocarbon force) (default :lsp "pyright,lua_ls,clangd,zls,csharp_ls,ts_ls,rust_analyzer" force))) diff --git a/fnl/layouts/ide.fnl b/fnl/layouts/ide.fnl new file mode 100644 index 0000000..8ba6182 --- /dev/null +++ b/fnl/layouts/ide.fnl @@ -0,0 +1,4 @@ +(fn [] +(vim.cmd "ToggleTerm direction=horizontal") +(vim.cmd "Neotree toggle") +(vim.cmd "Outline")) diff --git a/fnl/layouts/quiet.fnl b/fnl/layouts/quiet.fnl new file mode 100644 index 0000000..73d8b0f --- /dev/null +++ b/fnl/layouts/quiet.fnl @@ -0,0 +1,4 @@ +(fn [] +(tset vim.opt :number false) +(tset vim.o :signcolumn :no) +(tset vim.opt :fillchars {:eob " "})) diff --git a/fnl/opt.fnl b/fnl/opt.fnl index 17e4e0d..663fdee 100644 --- a/fnl/opt.fnl +++ b/fnl/opt.fnl @@ -11,13 +11,17 @@ (tset vim.opt :termguicolors true) ;--vim.opt.fillchars = { eob = ""} +(local color_change (fn [] + (vim.api.nvim_set_hl 0 :Normal {:bg :none}) + (vim.api.nvim_set_hl 0 :EndOfBuffer {:bg :none}) + (vim.api.nvim_set_hl 0 :NormalFloat {:bg :none}) + (vim.api.nvim_set_hl 0 :FloatBorder {:bg :none}))) + (when (= _G.settings.trans "enable") (vim.api.nvim_create_autocmd "Colorscheme" { :pattern :* - :callback (fn [] - (vim.api.nvim_set_hl 0 :Normal {:bg :none}) - (vim.api.nvim_set_hl 0 :NormalFloat {:bg :none}) - (vim.api.nvim_set_hl 0 :FloatBorder {:bg :none}))})) + :callback color_change}) + (color_change)) (vim.cmd (.. "colorscheme " _G.settings.colorscheme)) @@ -27,3 +31,6 @@ (vim.fn.mkdir target_path :p 0777)) (tset vim.o :undodir target_path) (tset vim.o :undofile true)) + +(when (not= _G.settings.layout "") + ((require (.. :layouts. _G.settings.layout)))) diff --git a/fnl/plugins/which_key.fnl b/fnl/plugins/which_key.fnl index e3279db..16b10a1 100644 --- a/fnl/plugins/which_key.fnl +++ b/fnl/plugins/which_key.fnl @@ -13,6 +13,7 @@ (wmap :t "ToggleTerm direction=horizontal" "hterm") (wmap :d "Glance references" "references") (wmap :s "Telescope live_grep" "search") + (wmap :z "Telescope find_files" "open file") (wmap :b "JABSOpen" "buffers") (wmap :g (fn [] (local buffer (vim.fn.expand :%)) @@ -27,10 +28,8 @@ ;;layouts (gmap :l "layout") - (wmap :li (fn [] - (vim.cmd "ToggleTerm direction=horizontal") - (vim.cmd "Neotree toggle") - (vim.cmd "Outline")) "ide") + (wmap :li (require :layouts.ide) "ide") + (wmap :lq (require :layouts.quiet) "quiet") ;;visual (gmap :v "visual") diff --git a/fnl/settings-ui.fnl b/fnl/settings-ui.fnl new file mode 100644 index 0000000..e7f32d3 --- /dev/null +++ b/fnl/settings-ui.fnl @@ -0,0 +1,59 @@ +(local options { + :colorscheme {:array false :options [:oxocarbon :monochrome :doom-one]} + :lsp {:array true}}) + +(local options_k {}) +(each [k v (pairs options)] (table.insert options_k k)) + +(lambda startswith [arr str] + (local end {}) + (each [_ a (pairs arr)] + (when (= (a:sub 1 (# str)) str) + (table.insert end a))) + end) + +(lambda trim [_str] + (var str _str) + (while (and (> (# str) 0) (= (str:sub 1 1) " ")) (set str (str:sub 2))) + (while (and (> (# str) 0) (= (str:sub -1 -1) " ")) (set str (str:sub 1 -2))) + str) + +(lambda carray [str] + (local word []) + (each [w (str:gmatch "([^,]+)")] (table.insert word w)) + word) + +(lambda tarray [arr] + (var string "") + (each [_ a (pairs arr)] + (set string (.. string "," a))) + string) + +(vim.api.nvim_create_user_command "Settings" + (fn [opts] + (var (option item rest) (opts.args:match "(%w+)%s*(%w+)(.*)")) + (var action 0) ; 0 = set, 1 = add, 2 = remove + (case item + (where n (= n "add")) (set action 1) + (where n (= n "remove")) (set action 2)) + + (when (= action 0) (tset _G.settings option (.. item " " rest))) + (when (= action 1) (tset _G.settings option (.. (. _G.settings option) rest))) + ) + {:nargs 1 :complete (fn [arglead cmdline] + (local parsed []) + (each [o (string.gmatch cmdline "%S+")] (table.insert parsed o)) + ;add an extra element when creating a new element + (when (= (cmdline:sub -1) " ") (table.insert parsed " ")) + + (case (# parsed) + (where n (= n 2)) (startswith options_k arglead) + (where n (and (= n 3) (?. options (. parsed 2) :array))) (startswith [:add :remove] arglead) + (where n (and (= n 4) (?. options (. parsed 2) :array) (= (. parsed 3) :remove))) (startswith (carray (. _G.settings (. parsed 2))) arglead) + + (where n (and (>= n 3) (?. options (. parsed 2) :options))) + ;only one for now, not sure what else i would add besides functions + (case (type (. options (. parsed 2) :options)) + (where n (= n "table")) (startswith (. options (. parsed 2) :options) arglead)) + + ))}) -- cgit v1.2.3