From 7096adce11b93787170c09b79a6170d97b4a977c Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Mon, 29 Jul 2024 00:03:58 +0200 Subject: Replace fn with λ and how cmds are imported MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fnl/plugins/alpha.fnl | 2 +- fnl/plugins/cmp.fnl | 2 +- fnl/plugins/colorscheme.fnl | 2 +- fnl/plugins/conform.fnl | 2 +- fnl/plugins/dadbod.fnl | 2 +- fnl/plugins/dial.fnl | 6 +++--- fnl/plugins/grug-far.fnl | 18 +++++++++--------- fnl/plugins/harpoon.fnl | 20 ++++++++++++-------- fnl/plugins/inc-rename.fnl | 2 +- fnl/plugins/leap.fnl | 2 +- fnl/plugins/lsp/diagnostics.fnl | 4 ++-- fnl/plugins/lsp/keymaps.fnl | 2 +- fnl/plugins/lsp/lspconfig.fnl | 10 +++++----- fnl/plugins/lsp/mason-lspconfig.fnl | 6 +++--- fnl/plugins/lsp/servers.fnl | 2 +- fnl/plugins/lualine.fnl | 4 ++-- fnl/plugins/neogit.fnl | 6 +++--- fnl/plugins/nvim-lint.fnl | 4 ++-- fnl/plugins/orgmode.fnl | 21 +++++++++++++-------- fnl/plugins/persistence.fnl | 6 +++--- fnl/plugins/snippets/org.fnl | 2 +- fnl/plugins/snippets/workflow.fnl | 4 ++-- fnl/plugins/telescope.fnl | 12 ++++++------ fnl/plugins/treesitter.fnl | 2 +- fnl/plugins/venn.fnl | 2 +- fnl/plugins/which-key.fnl | 2 +- fnl/plugins/window-picker.fnl | 6 +++--- fnl/settings/autocmds.fnl | 4 ++-- fnl/settings/cursorline.fnl | 8 ++++---- fnl/util/cmds.fnl | 4 ++-- 30 files changed, 89 insertions(+), 80 deletions(-) diff --git a/fnl/plugins/alpha.fnl b/fnl/plugins/alpha.fnl index 9f6bb24..7d6ad3d 100644 --- a/fnl/plugins/alpha.fnl +++ b/fnl/plugins/alpha.fnl @@ -21,7 +21,7 @@ " ..... " " . "]) -(fn config [] +(λ config [] (let [alpha (require :alpha)] (let [dashboard (require :alpha.themes.dashboard)] (set dashboard.section.header.val ascii-art) diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index f3c0211..6063462 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -8,7 +8,7 @@ :onsails/lspkind.nvim :saadparwaiz1/cmp_luasnip]) -(fn config [] +(λ config [] (let [cmp (require :cmp) lspkind (require :lspkind)] (lspkind.init) diff --git a/fnl/plugins/colorscheme.fnl b/fnl/plugins/colorscheme.fnl index ba63274..a9ec124 100644 --- a/fnl/plugins/colorscheme.fnl +++ b/fnl/plugins/colorscheme.fnl @@ -4,7 +4,7 @@ :lsp {:underline false} :match_paren {:underline true}}}) -(fn config [] +(λ config [] (let [plugin (require :no-clown-fiesta)] (plugin.setup opts) (plugin.load))) diff --git a/fnl/plugins/conform.fnl b/fnl/plugins/conform.fnl index f4cba63..3ad98aa 100644 --- a/fnl/plugins/conform.fnl +++ b/fnl/plugins/conform.fnl @@ -1,6 +1,6 @@ ;; Formatting -(fn init [] +(λ init [] (vim.keymap.set [:n :v] :e (lambda [] (let [conform (require :conform)] diff --git a/fnl/plugins/dadbod.fnl b/fnl/plugins/dadbod.fnl index c5ca5ec..733a4a0 100644 --- a/fnl/plugins/dadbod.fnl +++ b/fnl/plugins/dadbod.fnl @@ -15,7 +15,7 @@ :mode :n :desc "Add DB connection"}]) -(fn init [] +(λ init [] (set vim.g.db_ui_use_nerd_fonts 1) (set vim.g.db_ui_winwidth 40) (set vim.g.db_ui_notification_width 39)) diff --git a/fnl/plugins/dial.fnl b/fnl/plugins/dial.fnl index 7a888eb..0438529 100644 --- a/fnl/plugins/dial.fnl +++ b/fnl/plugins/dial.fnl @@ -1,19 +1,19 @@ ;; Better incrementation/decrementation. (local keys [{1 : - 2 (fn [] + 2 (λ [] (let [dial (require :dial.map)] (dial.inc_normal))) :expr true :desc :Increment} {1 : - 2 (fn [] + 2 (λ [] (let [dial (require :dial.map)] (dial.dec_normal))) :expr true :desc :Decrement}]) -(fn config [] +(λ config [] (let [cfg (require :dial.config) augend (require :dial.augend)] (cfg.augends:register_group {:default [augend.integer.alias.decimal diff --git a/fnl/plugins/grug-far.fnl b/fnl/plugins/grug-far.fnl index ed6eae1..44da9b1 100644 --- a/fnl/plugins/grug-far.fnl +++ b/fnl/plugins/grug-far.fnl @@ -5,7 +5,7 @@ :command "nnoremap q :close"}] [:FileType {:pattern [:grug-far] :command "setlocal spell!"}]]) -(fn replace [?cword ?file] +(λ replace [?cword ?file] (let [grug (require :grug-far)] (var opts {:prefills {}}) (when ?cword @@ -14,31 +14,31 @@ (set opts.prefills.flags ?file)) (grug.grug_far opts))) -(fn visual-replace [] +(λ visual-replace [] (let [grug (require :grug-far)] (grug.with_visual_selection {:prefills {:flags (vim.fn.expand "%")}}))) -(fn config [] - (let [cmds (require :util.cmds) +(λ config [] + (let [{: create-auto-cmds} (require :util.cmds) grug (require :grug-far)] - (cmds.create-auto-cmds auto-cmds) + (create-auto-cmds auto-cmds) (grug.setup))) (local keys [{1 : 2 :GrugFar :desc "Find and Replace"} {1 : - 2 (fn [] + 2 (λ [] (replace (vim.fn.expand :))) :desc "Find and replace word under cursor"} {1 : - 2 (fn [] + 2 (λ [] (replace nil (vim.fn.expand "%"))) :desc "Find and replace in file"} {1 : - 2 (fn [] + 2 (λ [] (replace (vim.fn.expand :) (vim.fn.expand "%"))) :desc "Find and replace cword in file"} {1 : - 2 (fn [] + 2 (λ [] (visual-replace)) :desc "Find and Replace" :mode [:v]}]) diff --git a/fnl/plugins/harpoon.fnl b/fnl/plugins/harpoon.fnl index c942183..723a52b 100644 --- a/fnl/plugins/harpoon.fnl +++ b/fnl/plugins/harpoon.fnl @@ -17,27 +17,31 @@ (let [harpoon (require :harpoon)] (: (harpoon:list) :select nr))) -(fn init [] - (let [cmds (require :util.cmds)] - (cmds.create-user-cmds user-cmds))) +(λ init [] + (let [{: create-user-cmds} (require :util.cmds)] + (create-user-cmds user-cmds))) (local keys [{1 :ma 2 :HarpoonAdd :desc :Harpoon} {1 :mr 2 :HarpoonUI :desc "Harpoon UI"} {1 :ms - 2 (fn [] + 2 (λ [] (select 1)) :desc "First Harpoon"} {1 :mt - 2 (fn [] + 2 (λ [] (select 2)) :desc "Second Harpoon"} {1 :mn - 2 (fn [] + 2 (λ [] (select 3)) :desc "Third Harpoon"} {1 :me - 2 (fn [] + 2 (λ [] (select 4)) :desc "Fourth Harpoon"}]) -{1 :ThePrimeagen/harpoon :branch :harpoon2 :event [:BufReadPost :BufNewFile] : init : keys} +{1 :ThePrimeagen/harpoon + :branch :harpoon2 + :event [:BufReadPost :BufNewFile] + : init + : keys} diff --git a/fnl/plugins/inc-rename.fnl b/fnl/plugins/inc-rename.fnl index bc50481..10ad4e4 100644 --- a/fnl/plugins/inc-rename.fnl +++ b/fnl/plugins/inc-rename.fnl @@ -2,6 +2,6 @@ {1 :smjonas/inc-rename.nvim : keys - :config (fn [] + :config (λ [] (let [inc-rename (require :inc_rename)] (inc-rename.setup)))} diff --git a/fnl/plugins/leap.fnl b/fnl/plugins/leap.fnl index 58b47e8..24bf6b9 100644 --- a/fnl/plugins/leap.fnl +++ b/fnl/plugins/leap.fnl @@ -29,7 +29,7 @@ ;; if the unnamed register is in use. :paste_on_remote_yank false}}]) -(fn config [] +(λ config [] (let [leap (require :leap)] (leap.setup {}) (leap.create_default_mappings) diff --git a/fnl/plugins/lsp/diagnostics.fnl b/fnl/plugins/lsp/diagnostics.fnl index 9fbb627..5956e0e 100644 --- a/fnl/plugins/lsp/diagnostics.fnl +++ b/fnl/plugins/lsp/diagnostics.fnl @@ -7,7 +7,7 @@ {:name :DiagnosticSignHint :text (. icons :hint)} {:name :DiagnosticSignInfo :text (. icons :info)}]) -(fn configure-signs [] +(λ configure-signs [] (each [_ sign (ipairs signs)] (vim.fn.sign_define sign.name {:texthl sign.name :text sign.text :numhl ""}))) @@ -23,7 +23,7 @@ :header "" :prefix ""}}) -(fn setup [] +(λ setup [] (configure-signs) (vim.diagnostic.config config) (set vim.lsp.handlers.textDocument/hover false) diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl index 2c01d15..72e03cd 100644 --- a/fnl/plugins/lsp/keymaps.fnl +++ b/fnl/plugins/lsp/keymaps.fnl @@ -40,7 +40,7 @@ [:n :K "lua vim.lsp.hover()" {:desc "Hover documentation"}] [:n :li :LspInfo {:desc "Lsp Info"}]]) -(fn on-attach [buffer] +(λ on-attach [buffer] (let [opts {:noremap true :silent true : buffer}] (each [_ mapping (ipairs mappings)] (match mapping diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl index a778eb3..112973b 100644 --- a/fnl/plugins/lsp/lspconfig.fnl +++ b/fnl/plugins/lsp/lspconfig.fnl @@ -1,13 +1,13 @@ ;; Configuration for lsp clients. -(fn on-attach [] +(λ on-attach [] (vim.api.nvim_create_autocmd :LspAttach - {:callback (fn [args] - (let [keymaps (require :plugins.lsp.keymaps) + {:callback (λ [args] + (let [{: on-attach} (require :plugins.lsp.keymaps) buffer (. args :buf)] - (keymaps.on-attach buffer)))})) + (on-attach buffer)))})) -(fn config [] +(λ config [] (on-attach) (let [diagnostics (require :plugins.lsp.diagnostics) mason-lspconfig (require :plugins.lsp.mason-lspconfig) diff --git a/fnl/plugins/lsp/mason-lspconfig.fnl b/fnl/plugins/lsp/mason-lspconfig.fnl index 21a07ad..105693e 100644 --- a/fnl/plugins/lsp/mason-lspconfig.fnl +++ b/fnl/plugins/lsp/mason-lspconfig.fnl @@ -1,11 +1,11 @@ ;; A bridge plugin between mason and lspconfig, handles installation of lsp and ;; setup hooks for client configurations. -(fn capabilities [] +(λ capabilities [] (let [cmp-lsp (require :cmp_nvim_lsp)] (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities)))) -(fn handlers [server] +(λ handlers [server] (let [servers (require :plugins.lsp.servers) lspconfig (require :lspconfig)] (let [config (. lspconfig server) @@ -13,7 +13,7 @@ (tset opts :capabilities (capabilities)) (config.setup opts)))) -(fn setup [] +(λ setup [] (let [mason-lspconfig (require :mason-lspconfig) servers (require :plugins.lsp.servers)] (mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers) diff --git a/fnl/plugins/lsp/servers.fnl b/fnl/plugins/lsp/servers.fnl index ab8cad6..0dbb16f 100644 --- a/fnl/plugins/lsp/servers.fnl +++ b/fnl/plugins/lsp/servers.fnl @@ -10,7 +10,7 @@ :settings {:json {:schemas (let [schemastore (require :schemastore)] (schemastore.json.schemas)) :validate {:enable true}}} - :setup {:commands {:Format [(fn [] + :setup {:commands {:Format [(λ [] (vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$" 0)]))]}}} diff --git a/fnl/plugins/lualine.fnl b/fnl/plugins/lualine.fnl index 0c11537..b2f7e14 100644 --- a/fnl/plugins/lualine.fnl +++ b/fnl/plugins/lualine.fnl @@ -14,7 +14,7 @@ (local ignore [:help :packer :spectre_panel :TelescopePrompt]) -(fn active-clients [] +(λ active-clients [] (let [clients (vim.lsp.get_clients) buf_num (vim.api.nvim_buf_get_number 0) client_names []] @@ -25,7 +25,7 @@ (table.concat client_names ", ") ""))) -(fn hide-in-width [] +(λ hide-in-width [] (> (vim.fn.winwidth 0) 80)) (local diagnostics {1 :diagnostics diff --git a/fnl/plugins/neogit.fnl b/fnl/plugins/neogit.fnl index a84c9dd..9b0c24b 100644 --- a/fnl/plugins/neogit.fnl +++ b/fnl/plugins/neogit.fnl @@ -11,9 +11,9 @@ :NeogitCommitView] :command "setlocal spell!"}]]) -(fn init [] - (let [cmds (require :util.cmds)] - (cmds.create-auto-cmds auto-cmds))) +(λ init [] + (let [{: create-auto-cmds} (require :util.cmds)] + (create-auto-cmds auto-cmds))) (local opts {:integrations {:diffview true :telescope true}}) diff --git a/fnl/plugins/nvim-lint.fnl b/fnl/plugins/nvim-lint.fnl index 2ea01fa..caa8d00 100644 --- a/fnl/plugins/nvim-lint.fnl +++ b/fnl/plugins/nvim-lint.fnl @@ -4,7 +4,7 @@ (let [lint (require :lint)] (lint.try_lint))) -(fn init [] +(λ init [] (let [lint-augroup (vim.api.nvim_create_augroup :lint {:clear true})] (vim.api.nvim_create_autocmd [:BufEnter :BufWritePost @@ -12,7 +12,7 @@ :TextChangedI] {:group lint-augroup : callback}))) -(fn config [] +(λ config [] (let [lint (require :lint)] (set lint.linters_by_ft {:* [:codespell :write_good] :dockerfile [:hadolint] diff --git a/fnl/plugins/orgmode.fnl b/fnl/plugins/orgmode.fnl index bf8ff0f..0868860 100644 --- a/fnl/plugins/orgmode.fnl +++ b/fnl/plugins/orgmode.fnl @@ -29,17 +29,17 @@ (local auto-cmds [[:FileType {:pattern :org - :callback (fn [] + :callback (λ [] (tset vim.opt_local :foldenable false) (tset vim.opt_local :foldlevelstart 0) (tset vim.opt_local :foldlevel 0) (tset vim.opt_local :concealcursor :nc) (tset vim.opt_local :conceallevel 2))}]]) -(fn init [] - (let [cmds (require :util.cmds)] - (cmds.create-user-cmds user-cmds) - (cmds.create-auto-cmds auto-cmds))) +(λ init [] + (let [{: create-auto-cmds : create-user-cmds} (require :util.cmds)] + (create-user-cmds user-cmds) + (create-auto-cmds auto-cmds))) (local templates {:t {:description :Todo :template "* TODO %?\n %u\n DEADLINE: %T\n"} @@ -77,12 +77,17 @@ (local roam-templates {:n {:description :node - :template "#+category: %^{type}\n#+filetags: %^{tags}\n#+date: %u\n\n* %?" + :template "#+category: %^{type} +#+filetags: %^{tags} +#+date: %u + +* %?" :target "%<%Y%m%d%H%M%S>-%[slug].org"}}) -(local roam-opts {:directory "~/.local/share/org/roam" :templates roam-templates}) +(local roam-opts {:directory "~/.local/share/org/roam" + :templates roam-templates}) -(fn config [] +(λ config [] (let [orgmode (require :orgmode) roam (require :org-roam) bullets (require :org-bullets)] diff --git a/fnl/plugins/persistence.fnl b/fnl/plugins/persistence.fnl index 1939564..6f5867c 100644 --- a/fnl/plugins/persistence.fnl +++ b/fnl/plugins/persistence.fnl @@ -24,9 +24,9 @@ (persistence.stop))) {:nargs 0}]]) -(fn init [] - (let [cmds (require :util.cmds)] - (cmds.create-user-cmds user-cmds))) +(λ init [] + (let [{: create-user-cmds} (require :util.cmds)] + (create-user-cmds user-cmds))) (local opts {:options [:buffers :curdir :tabpages :winsize :help]}) diff --git a/fnl/plugins/snippets/org.fnl b/fnl/plugins/snippets/org.fnl index a2b2e46..460e44c 100644 --- a/fnl/plugins/snippets/org.fnl +++ b/fnl/plugins/snippets/org.fnl @@ -1,6 +1,6 @@ ;; Snippets for org files. -(fn add-snippets [] +(λ add-snippets [] (let [ls (require :luasnip) fmt (require :luasnip.extras.fmt)] (let [s ls.s diff --git a/fnl/plugins/snippets/workflow.fnl b/fnl/plugins/snippets/workflow.fnl index ffe9f50..435cf90 100644 --- a/fnl/plugins/snippets/workflow.fnl +++ b/fnl/plugins/snippets/workflow.fnl @@ -1,4 +1,4 @@ -(fn workflow-snippets [] +(λ workflow-snippets [] (let [ls (require :luasnip) fmt (require :luasnip.extras.fmt)] (let [s ls.s @@ -33,7 +33,7 @@ substep \"{}\" = " [(i 1) (i 2) (i 3) (i 4) (i 5)]))]))) -(fn add-snippets [] +(λ add-snippets [] (let [ls (require :luasnip) snippets (workflow-snippets)] (ls.add_snippets :org snippets) diff --git a/fnl/plugins/telescope.fnl b/fnl/plugins/telescope.fnl index e0c0784..7b8f69b 100644 --- a/fnl/plugins/telescope.fnl +++ b/fnl/plugins/telescope.fnl @@ -38,11 +38,11 @@ :harpoon :rest]) -(fn load-extensions [telescope] +(λ load-extensions [telescope] (each [_ extension (ipairs extensions)] (telescope.load_extension extension))) -(fn telescope-builtin [builtin opts] +(λ telescope-builtin [builtin opts] (let [telescope (require :telescope.builtin) themes (require :telescope.themes) theme (. opts :theme)] @@ -54,9 +54,9 @@ {:theme :get_dropdown :previewer false})) {:nargs 0}]]) -(fn init [] - (let [cmds (require :util.cmds)] - (cmds.create-user-cmds user-cmds))) +(λ init [] + (let [{: create-user-cmds} (require :util.cmds)] + (create-user-cmds user-cmds))) (local keys [{1 :mf 2 :FindFiles :desc "Find Files"} {1 :mg @@ -103,7 +103,7 @@ 2 "Telescope git_commits theme=dropdown" :desc "Checkout Commit"}]) -(fn config [] +(λ config [] (let [telescope (require :telescope) actions (require :telescope.actions) icons (require :settings.icons)] diff --git a/fnl/plugins/treesitter.fnl b/fnl/plugins/treesitter.fnl index e7d20f9..650f132 100644 --- a/fnl/plugins/treesitter.fnl +++ b/fnl/plugins/treesitter.fnl @@ -83,7 +83,7 @@ :peek_definition_code {:md "@function.outer" :mD "@class.outer"}}}}) -(fn config [] +(λ config [] (let [treesitter (require :nvim-treesitter.configs)] (treesitter.setup opts))) diff --git a/fnl/plugins/venn.fnl b/fnl/plugins/venn.fnl index d1b42be..929e94d 100644 --- a/fnl/plugins/venn.fnl +++ b/fnl/plugins/venn.fnl @@ -26,7 +26,7 @@ (disable win))))) (local keys [{1 :v - 2 (fn [] + 2 (λ [] (toggle)) :desc "Toggle Venn Diagram"}]) diff --git a/fnl/plugins/which-key.fnl b/fnl/plugins/which-key.fnl index f78efac..db05b4d 100644 --- a/fnl/plugins/which-key.fnl +++ b/fnl/plugins/which-key.fnl @@ -49,7 +49,7 @@ 9 {1 :s :group :+session} 10 {1 :w :group :+worktree}}]) -(fn config [] +(λ config [] (let [which-key (require :which-key)] (which-key.setup opts) (which-key.add groups))) diff --git a/fnl/plugins/window-picker.fnl b/fnl/plugins/window-picker.fnl index 046e927..6746f00 100644 --- a/fnl/plugins/window-picker.fnl +++ b/fnl/plugins/window-picker.fnl @@ -4,16 +4,16 @@ :fg_color "#E1E1E1" :selection_chars :MNEIOARSTG}) -(fn pick-window [] +(λ pick-window [] (let [window-picker (require :window-picker)] (let [win (window-picker.pick_window)] (if (not= win nil) (vim.api.nvim_set_current_win win))))) -(fn config [] +(λ config [] (let [window-picker (require :window-picker)] (window-picker.setup opts) - (vim.keymap.set :n : (fn [] + (vim.keymap.set :n : (λ [] (pick-window)) {}))) {1 :s1n7ax/nvim-window-picker :event [:BufReadPost :BufNewFile] :version :2.0.0 : config} diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl index 5563f53..3b9cecb 100644 --- a/fnl/settings/autocmds.fnl +++ b/fnl/settings/autocmds.fnl @@ -23,5 +23,5 @@ (let [cursorline (require :settings.cursorline)] cursorline.hide))}]]) -(let [cmds (require :util.cmds)] - (cmds.create-auto-cmds auto-cmds)) +(let [{: create-auto-cmds} (require :util.cmds)] + (create-auto-cmds auto-cmds)) diff --git a/fnl/settings/cursorline.fnl b/fnl/settings/cursorline.fnl index cec76f2..7b7eae1 100644 --- a/fnl/settings/cursorline.fnl +++ b/fnl/settings/cursorline.fnl @@ -2,20 +2,20 @@ (local ignored [:neo-tree]) -(fn filetype [] +(λ filetype [] vim.bo.filetype) -(fn ignore [] +(λ ignore [] (vim.tbl_contains ignored (filetype))) -(fn show [] +(λ show [] (let [(ok cl) (pcall vim.api.nvim_win_get_var 0 :auto-cursorline)] (if (and ok cl) (do (set vim.wo.cursorline true) (vim.api.nvim_win_del_var 0 :auto-cursorline))))) -(fn hide [] +(λ hide [] (if (not= (ignore) true) (do (let [cl vim.wo.cursorline] diff --git a/fnl/util/cmds.fnl b/fnl/util/cmds.fnl index 254a26d..5881634 100644 --- a/fnl/util/cmds.fnl +++ b/fnl/util/cmds.fnl @@ -1,9 +1,9 @@ -(fn create-user-cmds [user-cmds] +(λ create-user-cmds [user-cmds] (each [_ user-cmd (ipairs user-cmds)] (match user-cmd [event cmd opts] (vim.api.nvim_create_user_command event cmd opts)))) -(fn create-auto-cmds [auto-cmds] +(λ create-auto-cmds [auto-cmds] (each [_ auto-cmd (ipairs auto-cmds)] (match auto-cmd [event opts] (vim.api.nvim_create_autocmd event opts)))) -- cgit v1.2.3-70-g09d2