summaryrefslogtreecommitdiff
path: root/fnl
diff options
context:
space:
mode:
authoraktersnurra <gustaf@gustafrydholm.xyz>2026-04-16 15:10:52 +0200
committeraktersnurra <gustaf@gustafrydholm.xyz>2026-04-17 23:28:47 +0200
commit152fd9d787c7433cad95795992e444250cb83216 (patch)
tree0ae3b4a3b42005dc08b1400981cfc4c1f37297fe /fnl
parent83a7f3505a441f1c152229d50a3d6011951a82fc (diff)
Add fff and other nice things such as macros
Diffstat (limited to 'fnl')
-rw-r--r--fnl/config.fnl11
-rw-r--r--fnl/macros.fnlm36
-rw-r--r--fnl/plugins/alpha.fnl49
-rw-r--r--fnl/plugins/bufdel.fnl5
-rw-r--r--fnl/plugins/cmp.fnl13
-rw-r--r--fnl/plugins/fff.fnl32
-rw-r--r--fnl/plugins/grug-far.fnl16
-rw-r--r--fnl/plugins/harpoon.fnl26
-rw-r--r--fnl/plugins/leap.fnl11
-rw-r--r--fnl/plugins/lsp.fnl30
-rw-r--r--fnl/plugins/lsp/diagnostics.fnl2
-rw-r--r--fnl/plugins/lsp/keymaps.fnl60
-rw-r--r--fnl/plugins/lsp/lspconfig.fnl25
-rw-r--r--fnl/plugins/lsp/mason-lspconfig.fnl7
-rw-r--r--fnl/plugins/lsp/mason.fnl14
-rw-r--r--fnl/plugins/lsp/servers.fnl6
-rw-r--r--fnl/plugins/neogit.fnl18
-rw-r--r--fnl/plugins/orgmode.fnl46
-rw-r--r--fnl/plugins/persistence.fnl36
-rw-r--r--fnl/plugins/snippets.fnl6
-rw-r--r--fnl/plugins/stay-in-place.fnl3
-rw-r--r--fnl/plugins/telescope.fnl24
-rw-r--r--fnl/plugins/treesitter-context.fnl13
-rw-r--r--fnl/plugins/which-key.fnl3
-rw-r--r--fnl/settings/autocmds.fnl54
-rw-r--r--fnl/settings/keymaps.fnl72
-rw-r--r--fnl/settings/options.fnl131
-rw-r--r--fnl/util/cmds.fnl11
-rw-r--r--fnl/util/load.fnl8
29 files changed, 321 insertions, 447 deletions
diff --git a/fnl/config.fnl b/fnl/config.fnl
index 478bae2..657c954 100644
--- a/fnl/config.fnl
+++ b/fnl/config.fnl
@@ -5,10 +5,9 @@
(local icons (require :settings.icons))
-(local {: apply-to-files} (require :util.load))
-
-(local api (require :hotpot.api))
-(local context (assert (api.context (vim.fn.stdpath :config))))
+(local context
+ (let [api (require :hotpot.api)]
+ (assert (api.context (vim.fn.stdpath :config)))))
(local opts {:install {:colorscheme [:no-clown-fiesta]}
:debug false
@@ -49,7 +48,9 @@
(require :settings)
(let [lazy (require :lazy)
plugins {}]
- (apply-to-files :/fnl/plugins (partial load-plugin plugins))
+ (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) :/fnl/plugins))]
+ (when (= type :file)
+ (load-plugin plugins (fname:match "^(.*)%.fnl$"))))
(vim.keymap.set :n :<leader>y "<cmd>Lazy home<cr>" {:desc :Home})
(lazy.setup plugins opts)))
diff --git a/fnl/macros.fnlm b/fnl/macros.fnlm
new file mode 100644
index 0000000..8267518
--- /dev/null
+++ b/fnl/macros.fnlm
@@ -0,0 +1,36 @@
+;; Fennel macros for compile-time expansion.
+
+(fn autocmd [event opts]
+ `(vim.api.nvim_create_autocmd ,event ,opts))
+
+(fn autocmds [...]
+ (let [out `(do)]
+ (each [_ cmd (ipairs [...])]
+ (table.insert out (autocmd (. cmd 1) (. cmd 2))))
+ out))
+
+(fn user-cmd [name cmd opts]
+ `(vim.api.nvim_create_user_command ,name ,cmd ,opts))
+
+(fn user-cmds [...]
+ (let [out `(do)]
+ (each [_ cmd (ipairs [...])]
+ (table.insert out (user-cmd (. cmd 1) (. cmd 2) (. cmd 3))))
+ out))
+
+(fn keymap [mode lhs rhs opts]
+ `(vim.keymap.set ,mode ,lhs ,rhs ,opts))
+
+(fn keymaps [...]
+ (let [out `(do)]
+ (each [_ mapping (ipairs [...])]
+ (table.insert out (keymap (. mapping 1) (. mapping 2) (. mapping 3) (. mapping 4))))
+ out))
+
+(fn set-opts [opts]
+ (let [out `(do)]
+ (each [k v (pairs opts)]
+ (table.insert out `(tset vim.opt ,k ,v)))
+ out))
+
+{: autocmd : autocmds : user-cmd : user-cmds : keymap : keymaps : set-opts}
diff --git a/fnl/plugins/alpha.fnl b/fnl/plugins/alpha.fnl
deleted file mode 100644
index 4011bcd..0000000
--- a/fnl/plugins/alpha.fnl
+++ /dev/null
@@ -1,49 +0,0 @@
-;; A customizable greeter.
-
-(local icons (require :settings.icons))
-
-(local ascii-art [" ##############..... ############## "
- " ##############......############## "
- " ##########..........########## "
- " ##########........########## "
- " ##########.......########## "
- " ##########.....##########.. "
- " ##########....##########..... "
- " ..##########..##########......... "
- " ....##########.#########............. "
- " ..################JJJ............ "
- " ################............. "
- " ##############.JJJ.JJJJJJJJJJ "
- " ############...JJ...JJ..JJ JJ "
- " ##########....JJ...JJ..JJ JJ "
- " ########......JJJ..JJJ JJJ JJJ "
- " ###### ......... "
- " ..... "
- " . "])
-
-(λ config []
- (let [alpha (require :alpha)]
- (let [dashboard (require :alpha.themes.dashboard)]
- (set dashboard.section.header.val ascii-art)
- (set dashboard.section.buttons.val
- [(dashboard.button :f (.. (. icons :search-files) " Find file")
- ":Telescope find_files theme=dropdown previewer=false<CR>")
- (dashboard.button :g (.. (. icons :search-text) " Find text")
- ":Telescope live_grep theme=dropdown<CR>")
- (dashboard.button :p
- (.. (. icons :search-project) " Find project")
- ":Telescope projects theme=dropdown<CR>")
- (dashboard.button :r
- (.. (. icons :recent-files)
- " Recently used files")
- ":Telescope oldfiles theme=dropdown previewer=false<CR>")
- (dashboard.button :t (.. (. icons :cog) " Configuration")
- ":e ~/.config/nvim/init.lua <CR>")
- (dashboard.button :o (.. (. icons :org) " Org")
- ":Telescope find_files theme=dropdown cwd=~/.local/share/org<CR>")])
- (set dashboard.section.header.opts.hl :AlphaHeader)
- (set dashboard.section.buttons.opts.hl :AlphaButtons)
- (set dashboard.opts.opts.noautocmd true)
- (alpha.setup dashboard.opts))))
-
-{1 :goolord/alpha-nvim :event :VimEnter : config}
diff --git a/fnl/plugins/bufdel.fnl b/fnl/plugins/bufdel.fnl
deleted file mode 100644
index e14287e..0000000
--- a/fnl/plugins/bufdel.fnl
+++ /dev/null
@@ -1,5 +0,0 @@
-;; Delete buffers.
-
-(local keys [{1 :<leader><BS> 2 :<cmd>BufDel<CR> :desc "Close Buffer"}])
-
-{1 :ojroques/nvim-bufdel :cmd :BufDel : keys}
diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl
index a979633..46efbc5 100644
--- a/fnl/plugins/cmp.fnl
+++ b/fnl/plugins/cmp.fnl
@@ -20,18 +20,7 @@
:dadbod {:name :Dadbod
:module :vim_dadbod_completion.blink
:score_offset 2}}}
- :snippets {:preset :luasnip
- :expand (λ [snippet]
- (let [luasnip (require :luasnip)]
- (luasnip.lsp_expand snippet)))
- :active (fn [filter]
- (let [luasnip (require :luasnip)]
- (when (and filter filter.direction)
- (luasnip.jumpable filter.direction))
- (luasnip.in_snippet)))
- :jump (λ [direction]
- (let [luasnip (require :luasnip)]
- (luasnip.jump direction)))}})
+ :snippets {:preset :luasnip}})
(local dependencies [:rafamadriz/friendly-snippets
{1 :L3MON4D3/LuaSnip :version :v2.*}])
diff --git a/fnl/plugins/fff.fnl b/fnl/plugins/fff.fnl
new file mode 100644
index 0000000..3939408
--- /dev/null
+++ b/fnl/plugins/fff.fnl
@@ -0,0 +1,32 @@
+;; Freakin fast fuzzy file finder.
+
+(import-macros {: autocmd} :macros)
+
+(λ init []
+ (autocmd :VimEnter
+ {:callback (λ []
+ (when (= (. (vim.fn.argv) 1) nil)
+ (vim.schedule
+ (λ [] ((. (require :fff) :find_files))))))
+ :once true}))
+
+(local opts {:layout {:height 0.8
+ :width 0.7
+ :prompt_position :bottom
+ :preview_position :top
+ :preview_size 0.8
+ :flex {:size 130 :wrap :top}
+ :show_scrollbar false
+ :path_shorten_strategy :middle_number}})
+
+{1 :dmtrKovalenko/fff.nvim
+ :build (λ []
+ ((. (require :fff.download) :build_binary)
+ (λ [ok err]
+ (vim.schedule
+ (λ [] (vim.notify (if ok "fff.nvim built!" err)))))))
+ : opts
+ :lazy false
+ : init
+ :keys [{1 :mf 2 (λ [] ((. (require :fff) :find_files))) :desc "Find Files"}
+ {1 :mg 2 (λ [] ((. (require :fff) :live_grep))) :desc "Live Grep"}]}
diff --git a/fnl/plugins/grug-far.fnl b/fnl/plugins/grug-far.fnl
index fdcf897..ebd1835 100644
--- a/fnl/plugins/grug-far.fnl
+++ b/fnl/plugins/grug-far.fnl
@@ -1,9 +1,6 @@
;; Find and replace plugin.
-(local auto-cmds
- [[:FileType
- {:pattern [:grug-far]
- :command "nnoremap <silent> <buffer> q :close<CR>"}]
- [:FileType {:pattern [:grug-far] :command "setlocal spell!"}]])
+
+(import-macros {: autocmds} :macros)
(λ replace [?cword ?file]
(let [grug (require :grug-far)]
@@ -19,9 +16,12 @@
(grug.with_visual_selection {:prefills {:paths (vim.fn.expand "%")}})))
(λ config []
- (let [{: create-auto-cmds} (require :util.cmds)
- grug (require :grug-far)]
- (create-auto-cmds auto-cmds)
+ (let [grug (require :grug-far)]
+ (autocmds
+ [:FileType
+ {:pattern [:grug-far]
+ :command "nnoremap <silent> <buffer> q :close<CR>"}]
+ [:FileType {:pattern [:grug-far] :command "setlocal spell!"}])
(grug.setup)))
(local keys [{1 :<m-w> 2 :<cmd>GrugFar<cr> :desc "Find and Replace"}
diff --git a/fnl/plugins/harpoon.fnl b/fnl/plugins/harpoon.fnl
index 3f8f7ac..29f41d0 100644
--- a/fnl/plugins/harpoon.fnl
+++ b/fnl/plugins/harpoon.fnl
@@ -1,28 +1,28 @@
;; Harpoon files for navigation.
+(import-macros {: user-cmds} :macros)
+
(local opts
{:ui_max_width 64
:title " ⇁ "
:settings {:save_on_toggle true :sync_on_ui_close true}})
-(local user-cmds [[:HarpoonAdd
- (λ []
- (let [harpoon (require :harpoon)]
- (: (harpoon:list) :add)))
- {:nargs 0}]
- [:HarpoonUI
- (λ []
- (let [harpoon (require :harpoon)]
- (harpoon.ui:toggle_quick_menu (harpoon:list) opts)))
- {:nargs 0}]])
-
(λ select [nr]
(let [harpoon (require :harpoon)]
(: (harpoon:list) :select nr)))
(λ init []
- (let [{: create-user-cmds} (require :util.cmds)]
- (create-user-cmds user-cmds)))
+ (user-cmds
+ [:HarpoonAdd
+ (λ []
+ (let [harpoon (require :harpoon)]
+ (: (harpoon:list) :add)))
+ {:nargs 0}]
+ [:HarpoonUI
+ (λ []
+ (let [harpoon (require :harpoon)]
+ (harpoon.ui:toggle_quick_menu (harpoon:list) opts)))
+ {:nargs 0}]))
(local keys [{1 :ma 2 :<cmd>HarpoonAdd<cr> :desc :Harpoon}
{1 :mr 2 :<cmd>HarpoonUI<cr> :desc "Harpoon UI"}
diff --git a/fnl/plugins/leap.fnl b/fnl/plugins/leap.fnl
index 397b873..0526109 100644
--- a/fnl/plugins/leap.fnl
+++ b/fnl/plugins/leap.fnl
@@ -1,12 +1,6 @@
;; Leap through text.
-(local dependencies [{1 :ggandor/flit.nvim
- :event :VimEnter
- :opts {:keys {:f :f :F :F :t :t :T :T}
- :labeled_modes :v
- :multiline true
- :opts {}}}
- {1 :tpope/vim-repeat :event :VeryLazy}
+(local dependencies [{1 :tpope/vim-repeat :event :VeryLazy}
{1 :aktersnurra/leap-spooky.nvim
:event :VeryLazy
:opts {;; Additional text objects, to be merged with the default ones.
@@ -32,7 +26,7 @@
(λ config []
(let [leap (require :leap)]
- (leap.setup {})
+ (tset leap.opts.vim_opts "go.ignorecase" false)
(vim.keymap.set [:n :x :o] :s "<Plug>(leap-forward)")
(vim.keymap.set [:n :x :o] :S "<Plug>(leap-backward)")
(vim.keymap.set [:x :o] :x "<Plug>(leap-forward-till)")
@@ -40,7 +34,6 @@
(vim.keymap.set [:n] :gs "<Plug>(leap-from-window)")))
{:url "https://codeberg.org/andyg/leap.nvim"
-:name :leap.nvim
: dependencies
:event :VeryLazy
: config}
diff --git a/fnl/plugins/lsp.fnl b/fnl/plugins/lsp.fnl
index f04ba86..482916a 100644
--- a/fnl/plugins/lsp.fnl
+++ b/fnl/plugins/lsp.fnl
@@ -1,3 +1,29 @@
-;; Lsp plugins.
+;; LSP configuration.
-[(require :plugins.lsp.lspconfig) (require :plugins.lsp.mason)]
+(λ config []
+ (vim.api.nvim_create_autocmd :LspAttach
+ {:callback (λ [args]
+ (let [{: on-attach} (require :plugins.lsp.keymaps)]
+ (on-attach args.buf)))})
+ (let [diagnostics (require :plugins.lsp.diagnostics)
+ mason-lspconfig (require :plugins.lsp.mason-lspconfig)]
+ (diagnostics.setup)
+ (mason-lspconfig.setup)))
+
+(local icons (require :settings.icons))
+
+[{1 :neovim/nvim-lspconfig
+ :event :BufNew
+ :dependencies [:mason.nvim
+ :williamboman/mason-lspconfig.nvim
+ :b0o/schemastore.nvim
+ :saghen/blink.cmp]
+ : config}
+ {1 :williamboman/mason.nvim
+ :cmd :Mason
+ :keys [{1 :<leader>m 2 :<cmd>Mason<cr> :desc :Mason}]
+ :opts {:ui {:border :single
+ :icons {:package_installed (.. (. icons :checkmark) " ")
+ :package_pending (.. (. icons :arrow-right) " ")
+ :package_uninstalled (.. (. icons :close) " ")}}
+ :max_concurrent_installers 10}}]
diff --git a/fnl/plugins/lsp/diagnostics.fnl b/fnl/plugins/lsp/diagnostics.fnl
index b4aefa6..b8bf5cc 100644
--- a/fnl/plugins/lsp/diagnostics.fnl
+++ b/fnl/plugins/lsp/diagnostics.fnl
@@ -15,7 +15,7 @@
:float {:focusable false
:style :minimal
:border :single
- :source :always
+ :source true
:header ""
:prefix ""}})
diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl
index f312581..3477f0a 100644
--- a/fnl/plugins/lsp/keymaps.fnl
+++ b/fnl/plugins/lsp/keymaps.fnl
@@ -1,50 +1,22 @@
;; Key mappings for lsp.
-(local mappings
- [[:n :gD "<cmd>lua vim.lsp.buf.declaration()<CR>" {:desc :Declaration}]
- [:n
- :gd
- "<cmd>Telescope lsp_definitions theme=get_dropdown<cr>"
- {:desc :Definition}]
- [:n
- :gI
- "<cmd>Telescope lsp_implementations theme=get_dropdown<cr>"
- {:desc :Implementation}]
- [:n
- :gr
- "<cmd>Telescope lsp_references theme=get_dropdown<cr>"
- {:desc :References}]
- [:n
- :gl
- "<cmd>lua vim.diagnostic.open_float()<CR>"
- {:desc :Diagnostics}]
- [:n
- :gj
- "<cmd>Telescope diagnostics theme=get_dropdown<cr>"
- {:desc "Telescope Diagnostics"}]
- [:n
- :gw
- "<cmd>Telescope lsp_dynamic_workspace_symbols theme=get_dropdown<cr>"
- {:desc "Workspace Symbols"}]
- [:n
- :gE
- "<cmd>Telescope lsp_type_definitions theme=get_dropdown<cr>"
- {:desc "Type Definitions"}]
- [:n :gm "<cmd>lua vim.lsp.buf.signature_help()<CR>" {:desc :Signature}]
- [:n
- :gM
- "<cmd>Telescope lsp_document_symbols theme=get_dropdown<cr>"
- {:desc "Document Symbols"}]
- [:n :gh "<cmd>lua vim.lsp.buf.code_action()<cr>" {:desc "Code Action"}]
- [:n :gb "<cmd>lua vim.lsp.codelens.run()<cr>" {:desc "Code Lens"}]
- [:n :K "<cmd>lua vim.lsp.buf.hover()<cr>" {:desc "Hover documentation"}]
- [:n :<leader>li :<cmd>LspInfo<cr> {:desc "Lsp Info"}]])
+(import-macros {: keymaps} :macros)
(λ on-attach [buffer]
- (let [opts {:noremap true :silent true : buffer}]
- (each [_ mapping (ipairs mappings)]
- (match mapping
- [mode key cmd desc]
- (vim.keymap.set mode key cmd (vim.tbl_extend :force opts desc))))))
+ (keymaps
+ [:n :gD "<cmd>lua vim.lsp.buf.declaration()<CR>" {:desc :Declaration :buffer buffer}]
+ [:n :gd "<cmd>Telescope lsp_definitions theme=get_dropdown<cr>" {:desc :Definition :buffer buffer}]
+ [:n :gI "<cmd>Telescope lsp_implementations theme=get_dropdown<cr>" {:desc :Implementation :buffer buffer}]
+ [:n :gr "<cmd>Telescope lsp_references theme=get_dropdown<cr>" {:desc :References :buffer buffer}]
+ [:n :gl "<cmd>lua vim.diagnostic.open_float()<CR>" {:desc :Diagnostics :buffer buffer}]
+ [:n :gj "<cmd>Telescope diagnostics theme=get_dropdown<cr>" {:desc "Telescope Diagnostics" :buffer buffer}]
+ [:n :gw "<cmd>Telescope lsp_dynamic_workspace_symbols theme=get_dropdown<cr>" {:desc "Workspace Symbols" :buffer buffer}]
+ [:n :gE "<cmd>Telescope lsp_type_definitions theme=get_dropdown<cr>" {:desc "Type Definitions" :buffer buffer}]
+ [:n :gm "<cmd>lua vim.lsp.buf.signature_help()<CR>" {:desc :Signature :buffer buffer}]
+ [:n :gM "<cmd>Telescope lsp_document_symbols theme=get_dropdown<cr>" {:desc "Document Symbols" :buffer buffer}]
+ [:n :gh "<cmd>lua vim.lsp.buf.code_action()<cr>" {:desc "Code Action" :buffer buffer}]
+ [:n :gb "<cmd>lua vim.lsp.codelens.run()<cr>" {:desc "Code Lens" :buffer buffer}]
+ [:n :K "<cmd>lua vim.lsp.buf.hover()<cr>" {:desc "Hover documentation" :buffer buffer}]
+ [:n :<leader>li :<cmd>LspInfo<cr> {:desc "Lsp Info" :buffer buffer}]))
{: on-attach}
diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl
deleted file mode 100644
index 192954c..0000000
--- a/fnl/plugins/lsp/lspconfig.fnl
+++ /dev/null
@@ -1,25 +0,0 @@
-;; Configuration for lsp clients.
-
-(λ on-attach []
- (vim.api.nvim_create_autocmd :LspAttach
- {:callback (λ [args]
- (let [{: on-attach} (require :plugins.lsp.keymaps)
- buffer (. args :buf)]
- (on-attach buffer)))}))
-
-(λ config []
- (on-attach)
- (let [diagnostics (require :plugins.lsp.diagnostics)
- mason-lspconfig (require :plugins.lsp.mason-lspconfig)
- ui (require :lspconfig.ui.windows)]
- (set ui.default_options.border :single)
- (diagnostics.setup)
- (mason-lspconfig.setup)))
-
-{1 :neovim/nvim-lspconfig
- :event :BufNew
- :dependencies [:mason.nvim
- :williamboman/mason-lspconfig.nvim
- :b0o/schemastore.nvim
- :saghen/blink.cmp]
- : config}
diff --git a/fnl/plugins/lsp/mason-lspconfig.fnl b/fnl/plugins/lsp/mason-lspconfig.fnl
index 48ea0b5..36b98c2 100644
--- a/fnl/plugins/lsp/mason-lspconfig.fnl
+++ b/fnl/plugins/lsp/mason-lspconfig.fnl
@@ -1,10 +1,6 @@
-;; A bridge plugin between mason and lspconfig, handles installation of lsp and
+;; A bridge plugin between mason and lspconfig, handles installation of lsp and
;; setup hooks for client configurations.
-(local textDocument-handlers
- {:textDocument/hover (vim.lsp.with vim.lsp.handlers.hover)
- :textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help)})
-
(λ capabilities []
(let [blink-cmp (require :blink.cmp)]
(blink-cmp.get_lsp_capabilities)))
@@ -15,7 +11,6 @@
(let [lspconfig (. lspconfigs server)
server-config (or (. servers server) {})]
(tset server-config :capabilities (capabilities))
- (tset server-config :handlers textDocument-handlers)
(lspconfig.setup server-config))))
(λ setup []
diff --git a/fnl/plugins/lsp/mason.fnl b/fnl/plugins/lsp/mason.fnl
deleted file mode 100644
index e9c59ea..0000000
--- a/fnl/plugins/lsp/mason.fnl
+++ /dev/null
@@ -1,14 +0,0 @@
-;; Mason manages external tooling, e.g. lsp, formatters, and linters.
-
-(local icons (require :settings.icons))
-
-(local opts {:ui {:border :single
- :icons {:package_installed (.. (. icons :checkmark) " ")
- :package_pending (.. (. icons :arrow-right) " ")
- :package_uninstalled (.. (. icons :close) " ")}}
- :max_concurrent_installers 10})
-
-{1 :williamboman/mason.nvim
- :cmd :Mason
- :keys [{1 :<leader>m 2 :<cmd>Mason<cr> :desc :Mason}]
- : opts}
diff --git a/fnl/plugins/lsp/servers.fnl b/fnl/plugins/lsp/servers.fnl
index 7d213a8..13c6c9e 100644
--- a/fnl/plugins/lsp/servers.fnl
+++ b/fnl/plugins/lsp/servers.fnl
@@ -10,11 +10,7 @@
:jsonls {:init_options {:providerFormatter false}
:settings {:json {:schemas (let [schemastore (require :schemastore)]
(schemastore.json.schemas))
- :validate {:enable true}}}
- :setup {:commands {:Format [(λ []
- (vim.lsp.buf.range_formatting [] [0 0]
- [(vim.fn.line "$"
- 0)]))]}}}
+ :validate {:enable true}}}}
:ocamllsp {}
:rust_analyzer {:settings {:rust-analyzer {:lens {:enable true}
:checkOnSave {:command :clippy}}}}
diff --git a/fnl/plugins/neogit.fnl b/fnl/plugins/neogit.fnl
index 9b0c24b..143699d 100644
--- a/fnl/plugins/neogit.fnl
+++ b/fnl/plugins/neogit.fnl
@@ -1,19 +1,19 @@
;; Git ui.
+(import-macros {: autocmds} :macros)
+
(local dependencies [:nvim-lua/plenary.nvim])
(local keys [{1 :<leader>gm 2 :<cmd>Neogit<cr> :desc :Neogit}])
-(local auto-cmds [[:FileType
- {:pattern [:NeogitStatus
- :NeogitCommitMessage
- :NeogitNotification
- :NeogitCommitView]
- :command "setlocal spell!"}]])
-
(λ init []
- (let [{: create-auto-cmds} (require :util.cmds)]
- (create-auto-cmds auto-cmds)))
+ (autocmds
+ [:FileType
+ {:pattern [:NeogitStatus
+ :NeogitCommitMessage
+ :NeogitNotification
+ :NeogitCommitView]
+ :command "setlocal spell!"}]))
(local opts {:integrations {:diffview true :telescope true}})
diff --git a/fnl/plugins/orgmode.fnl b/fnl/plugins/orgmode.fnl
index 04cd3b4..60bc15c 100644
--- a/fnl/plugins/orgmode.fnl
+++ b/fnl/plugins/orgmode.fnl
@@ -1,5 +1,7 @@
;; Orgmode for nvim.
+(import-macros {: autocmds : user-cmds} :macros)
+
(local icons (require :settings.icons))
(local keys [{1 :<leader>oa
@@ -15,31 +17,27 @@
2 "<cmd>Telescope orgmode search_headings theme=dropdown<cr>"
:desc "Search headings"}])
-(local user-cmds [[:OrgAgendaPrompt
- (λ []
- (let [orgmode (require :orgmode)]
- (orgmode.action :agenda.prompt)))
- {:nargs 0}]
- [:OrgCapturePrompt
- (λ []
- (let [orgmode (require :orgmode)]
- (orgmode.action :capture.prompt)))
- {:nargs 0}]])
-
-(local auto-cmds
- [[:FileType
- {:pattern :org
- :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))}]])
-
(λ init []
- (let [{: create-auto-cmds : create-user-cmds} (require :util.cmds)]
- (create-user-cmds user-cmds)
- (create-auto-cmds auto-cmds)))
+ (user-cmds
+ [:OrgAgendaPrompt
+ (λ []
+ (let [orgmode (require :orgmode)]
+ (orgmode.action :agenda.prompt)))
+ {:nargs 0}]
+ [:OrgCapturePrompt
+ (λ []
+ (let [orgmode (require :orgmode)]
+ (orgmode.action :capture.prompt)))
+ {:nargs 0}])
+ (autocmds
+ [:FileType
+ {:pattern :org
+ :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))}]))
(local templates
{:t {:description :Todo :template "* TODO %?\n %u\n DEADLINE: %T\n"}
diff --git a/fnl/plugins/persistence.fnl b/fnl/plugins/persistence.fnl
index e84ec58..2e81e78 100644
--- a/fnl/plugins/persistence.fnl
+++ b/fnl/plugins/persistence.fnl
@@ -1,5 +1,7 @@
;; Session manager.
+(import-macros {: user-cmds} :macros)
+
(local keys [{1 :<leader>sn 2 :<cmd>RestoreSession<cr> :desc "Restore session"}
{1 :<leader>se
2 :<cmd>RestoreLastSession<cr>
@@ -8,25 +10,23 @@
2 :<cmd>IgnoreSession<cr>
:desc "Ignore current session"}])
-(local user-cmds [[:RestoreSession
- (λ []
- (let [persistence (require :persistence)]
- (persistence.load)))
- {:nargs 0}]
- [:RestoreLastSession
- (λ []
- (let [persistence (require :persistence)]
- (persistence.load {:last true})))
- {:nargs 0}]
- [:IgnoreSession
- (λ []
- (let [persistence (require :persistence)]
- (persistence.stop)))
- {:nargs 0}]])
-
(λ init []
- (let [{: create-user-cmds} (require :util.cmds)]
- (create-user-cmds user-cmds)))
+ (user-cmds
+ [:RestoreSession
+ (λ []
+ (let [persistence (require :persistence)]
+ (persistence.load)))
+ {:nargs 0}]
+ [:RestoreLastSession
+ (λ []
+ (let [persistence (require :persistence)]
+ (persistence.load {:last true})))
+ {:nargs 0}]
+ [:IgnoreSession
+ (λ []
+ (let [persistence (require :persistence)]
+ (persistence.stop)))
+ {:nargs 0}]))
(local opts {:options [:buffers :curdir :tabpages :winsize :help]})
diff --git a/fnl/plugins/snippets.fnl b/fnl/plugins/snippets.fnl
index fbfaeac..c45d220 100644
--- a/fnl/plugins/snippets.fnl
+++ b/fnl/plugins/snippets.fnl
@@ -6,13 +6,13 @@
(let [snippets (require (.. :plugins.snippets. name))]
(snippets.add-snippets)))
-(local {: apply-to-files} (require :util.load))
-
(λ config []
(let [ls (require :luasnip)
luasnip-vscode (require :luasnip.loaders.from_vscode)]
(luasnip-vscode.lazy_load)
- (apply-to-files :/fnl/plugins/snippets add-snippets)
+ (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) :/fnl/plugins/snippets))]
+ (when (= type :file)
+ (add-snippets (fname:match "^(.*)%.fnl$"))))
(ls.config.set_config {:history true
:updateevents "TextChanged,TextChangedI"})
(vim.keymap.set [:i :s] :<c-u>
diff --git a/fnl/plugins/stay-in-place.fnl b/fnl/plugins/stay-in-place.fnl
deleted file mode 100644
index 69066d7..0000000
--- a/fnl/plugins/stay-in-place.fnl
+++ /dev/null
@@ -1,3 +0,0 @@
-;; Keep cursor at character when indenting.
-
-{1 :gbprod/stay-in-place.nvim :event :BufRead :config true}
diff --git a/fnl/plugins/telescope.fnl b/fnl/plugins/telescope.fnl
index 0facab9..3932d84 100644
--- a/fnl/plugins/telescope.fnl
+++ b/fnl/plugins/telescope.fnl
@@ -1,11 +1,7 @@
;; Telescope a highly extendable fuzzy finder over lists.
(local dependencies
- [:nvim-lua/popup.nvim
- :nvim-telescope/telescope-frecency.nvim
- {1 :nvim-telescope/telescope-fzf-native.nvim :build :make}
- :tami5/sqlite.lua
- {1 :ahmedkhalf/project.nvim
+ [{1 :ahmedkhalf/project.nvim
:event :VeryLazy
:opts {:active true
:on_config_done nil
@@ -26,23 +22,15 @@
(let [project (require :project_nvim)]
(project.setup opts)))}
:nvim-lua/plenary.nvim
- :nvim-telescope/telescope-fzf-native.nvim
- :nvim-telescope/telescope-frecency.nvim
{1 :nvim-orgmode/telescope-orgmode.nvim}])
-(local extensions [:fzf :frecency :orgmode :projects :git_worktree :harpoon])
+(local extensions [:orgmode :projects :git_worktree :harpoon])
(λ load-extensions [telescope]
(each [_ extension (ipairs extensions)]
(telescope.load_extension extension)))
-(local keys [{1 :mf
- 2 "<cmd>Telescope find_files theme=dropdown previewer=false disable_devicons=true<cr>"
- :desc "Find Files"}
- {1 :mg
- 2 "<cmd>Telescope live_grep theme=dropdown<cr>"
- :desc "Find Text"}
- {1 :mb
+(local keys [{1 :mb
2 "<cmd>Telescope buffers theme=dropdown previewer=true initial_mode=normal<cr>"
:desc "Switch Buffer"}
{1 :<leader>fC
@@ -102,11 +90,7 @@
:--line-number
:--column
:--smart-case
- :--hidden]}
- :extensions {:fzf {:fuzzy true
- :override_generic_sorter true
- :override_file_sorter true
- :case_mode :smart_case}}})
+ :--hidden]}})
(load-extensions telescope)))
{1 :nvim-telescope/telescope.nvim
diff --git a/fnl/plugins/treesitter-context.fnl b/fnl/plugins/treesitter-context.fnl
new file mode 100644
index 0000000..f7730bd
--- /dev/null
+++ b/fnl/plugins/treesitter-context.fnl
@@ -0,0 +1,13 @@
+;; Sticky context headers while scrolling.
+
+(local opts {:enable true
+ :max_lines 3
+ :min_window_height 0
+ :line_numbers true
+ :multiline_threshold 20
+ :trim_scope :outer
+ :mode :cursor
+ :separator nil
+ :zindex 20})
+
+{1 :nvim-treesitter/nvim-treesitter-context :event [:BufReadPre :BufNewFile] : opts}
diff --git a/fnl/plugins/which-key.fnl b/fnl/plugins/which-key.fnl
index c32613c..189a4a4 100644
--- a/fnl/plugins/which-key.fnl
+++ b/fnl/plugins/which-key.fnl
@@ -47,7 +47,8 @@
7 {1 :<leader>o :group :+orgmode}
8 {1 :<leader>r :group :+replace}
9 {1 :<leader>s :group :+session}
- 10 {1 :<leader>w :group :+worktree}}])
+ 10 {1 :<leader>w :group :+worktree}}
+ {1 :<leader><BS> 2 "<cmd>bdelete<cr>" :desc "Close Buffer"}])
(λ config []
(let [which-key (require :which-key)]
diff --git a/fnl/settings/autocmds.fnl b/fnl/settings/autocmds.fnl
index 9b5eac5..2f0a3cd 100644
--- a/fnl/settings/autocmds.fnl
+++ b/fnl/settings/autocmds.fnl
@@ -1,30 +1,30 @@
;; Autocommands for nvim.
-(local auto-cmds [[:FileType
- {:pattern [:qf :help :man :lspinfo]
- :command "nnoremap <silent> <buffer> q :close<CR>"}]
- [:TextYankPost
- {:callback (λ []
- (vim.highlight.on_yank {:higroup :Visual
- :timeout 200}))}]
- [:BufWinEnter {:command "setlocal formatoptions-=cro"}]
- [:FileType {:pattern :qf :command "set nobuflisted"}]
- [:FileType
- {:pattern [:gitcommit :markdown] :command "setlocal wrap"}]
- [:VimResized {:command "tabdo wincmd ="}]
- [[:FocusGained :BufEnter :CursorHold :CursorHoldI]
- {:pattern "*"
- :callback (fn []
- (when (= (vim.fn.mode) :n)
- (vim.cmd :checktime)))}]
- [[:InsertLeave :WinEnter]
- {:callback (λ []
- (let [cursorline (require :settings.cursorline)]
- cursorline.show))}]
- [[:InsertEnter :WinLeave]
- {:callback (λ []
- (let [cursorline (require :settings.cursorline)]
- cursorline.hide))}]])
+(import-macros {: autocmds} :macros)
-(let [{: create-auto-cmds} (require :util.cmds)]
- (create-auto-cmds auto-cmds))
+(autocmds
+ [:FileType
+ {:pattern [:qf :help :man :lspinfo]
+ :command "nnoremap <silent> <buffer> q :close<CR>"}]
+ [:TextYankPost
+ {:callback (λ []
+ (vim.highlight.on_yank {:higroup :Visual
+ :timeout 200}))}]
+ [:BufWinEnter {:command "setlocal formatoptions-=cro"}]
+ [:FileType {:pattern :qf :command "set nobuflisted"}]
+ [:FileType
+ {:pattern [:gitcommit :markdown] :command "setlocal wrap"}]
+ [:VimResized {:command "tabdo wincmd ="}]
+ [[:FocusGained :BufEnter :CursorHold :CursorHoldI]
+ {:pattern "*"
+ :callback (fn []
+ (when (= (vim.fn.mode) :n)
+ (vim.cmd :checktime)))}]
+ [[:InsertLeave :WinEnter]
+ {:callback (λ []
+ (let [cursorline (require :settings.cursorline)]
+ cursorline.show))}]
+ [[:InsertEnter :WinLeave]
+ {:callback (λ []
+ (let [cursorline (require :settings.cursorline)]
+ cursorline.hide))}])
diff --git a/fnl/settings/keymaps.fnl b/fnl/settings/keymaps.fnl
index 14cd160..fcc7511 100644
--- a/fnl/settings/keymaps.fnl
+++ b/fnl/settings/keymaps.fnl
@@ -1,44 +1,34 @@
;; Custom keymappings.
-(local opts {:noremap true :silent true})
+(import-macros {: keymaps} :macros)
-(local mappings [;;Remap space as leader key
- ["" :<Space> :<Nop> {}]
- ;; Normal ;;
- ;; Resize with arrows
- [:n :<m-f> :<c-w>+ {}]
- [:n :<m-p> :<c-w>- {}]
- [:n "<m-,>" :<c-w>5< {}]
- [:n :<m-.> :<c-w>5> {}]
- ;; Visual ;;
- ;; Stay in indent mode
- [:v "<" :<gv {}]
- [:v ">" :>gv {}]
- ;; Visual Block ;;
- ;; Move text up and down
- [:x :J ":move '>+1<CR>gv-gv" {}]
- [:x :K ":move '<-2<CR>gv-gv" {}]
- ;; Move text up and down
- [:v :<c-n> ":m .+1<CR>==" {}]
- [:v :<c-e> ":m .-2<CR>==" {}]
- [:v :p "\"_dP" {}]
- ;; Splits
- [:n :<m-s> :<cmd>split<CR> {}]
- [:n :<m-t> :<cmd>vsplit<CR> {}]
- ;; Buf navigation
- [:n :<c-n> :<cmd>bprev<CR> {}]
- [:n :<c-e> :<cmd>bnext<CR> {}]
- ;; Jump half a page and centralize the view
- [:n :<c-d> :<c-d>zz {}]
- [:n :<c-u> :<c-u>zz {}]
- ;; Remove highlighted search
- [:n :<m-h> :<cmd>nohlsearch<CR> {}]
- ;; jump to eol in insert mode
- [:i :<c-e> :<c-o>$ {}]
- ;; Force refresh
- [:n :mj "<cmd>:e<CR>" {:desc :Refresh}]])
-
-(each [_ mapping (ipairs mappings)]
- (match mapping
- [mode key cmd desc]
- (vim.api.nvim_set_keymap mode key cmd (vim.tbl_extend :force opts desc))))
+(keymaps
+ ;; Resize with arrows
+ [:n :<m-f> :<c-w>+ {}]
+ [:n :<m-p> :<c-w>- {}]
+ [:n "<m-,>" :<c-w>5< {}]
+ [:n :<m-.> :<c-w>5> {}]
+ ;; Stay in indent mode
+ [:v "<" :<gv {}]
+ [:v ">" :>gv {}]
+ ;; Move text up and down
+ [:x :J ":move '>+1<CR>gv-gv" {}]
+ [:x :K ":move '<-2<CR>gv-gv" {}]
+ [:v :<c-n> ":m .+1<CR>==" {}]
+ [:v :<c-e> ":m .-2<CR>==" {}]
+ [:v :p "\"_dP" {}]
+ ;; Splits
+ [:n :<m-s> :<cmd>split<CR> {}]
+ [:n :<m-t> :<cmd>vsplit<CR> {}]
+ ;; Buf navigation
+ [:n :<c-n> :<cmd>bprev<CR> {}]
+ [:n :<c-e> :<cmd>bnext<CR> {}]
+ ;; Jump half a page and centralize the view
+ [:n :<c-d> :<c-d>zz {}]
+ [:n :<c-u> :<c-u>zz {}]
+ ;; Remove highlighted search
+ [:n :<m-h> :<cmd>nohlsearch<CR> {}]
+ ;; Jump to eol in insert mode
+ [:i :<c-e> :<c-o>$ {}]
+ ;; Force refresh
+ [:n :mj "<cmd>:e<CR>" {:desc :Refresh}])
diff --git a/fnl/settings/options.fnl b/fnl/settings/options.fnl
index e7ece5f..a659aae 100644
--- a/fnl/settings/options.fnl
+++ b/fnl/settings/options.fnl
@@ -1,91 +1,54 @@
;; Sets options in neovim
-(local spellfile (.. (os.getenv :XDG_CONFIG_HOME) :/nvim/spell/en.utf-8.add))
+(import-macros {: set-opts} :macros)
-(local opts {;; creates a backup file
- :backup false
- ;; allows neovim to access the system clipboard
- :clipboard :unnamedplus
- ;; more space in the neovim command line for displaying messages
- :cmdheight 1
- ;; mostly just for cmp
- :completeopt {:menuone :noselect}
- ;; so that `` is visible in markdown files
- :conceallevel 0
- ;; the encoding written to a file
- :fileencoding :utf-8
- ;; highlight all matches on previous search pattern
- :hlsearch true
- ;; ignore case in search patterns
- :ignorecase true
- ;; disable the mouse to be used in neovim
- :mouse ""
- ;; pop up menu height
- :pumheight 10
- ;; we don't need to see things like ;; INSERT ;; anymore
- :showmode false
- ;; never show tabs
- :showtabline 0
- ;; smart case
- :smartcase true
- ;; make indenting smarter again
- :smartindent true
- ;; force all horizontal splits to go below current window
- :splitbelow true
- ;; force all vertical splits to go to the right of current window
- :splitright true
- ;; creates a swapfile
- :swapfile false
- ;; set term gui colors (most terminals support this)
- :termguicolors true
- ;; time to wait for a mapped sequence to complete (in milliseconds)
- :timeoutlen 1000
- ;; enable persistent undo
- :undofile true
- ;; faster completion (4000ms default)
- :updatetime 1000
- ;; if a file is being edited by another program (or was written
- ;; to file while editing with another program), it is not allowed
- ;; to be edited
- :writebackup false
- ;; convert tabs to spaces
- :expandtab true
- ;; the number of spaces inserted for each indentation
- :shiftwidth 2
- ;; insert 2 spaces for a tab
- :tabstop 2
- ;; highlight the current line
- :cursorline true
- ;; set numbered lines
- :number true
- ;; set relative numbered lines
- :relativenumber true
- ;; set number column width to 2 {default 4}
- :numberwidth 2
- ;; always show the sign column, otherwise it would shift the text
- ;; each time
- :signcolumn :yes
- ;; display lines as one long line
- :wrap false
- :laststatus 3
- :autoread true
- ;; is one of my fav
- :scrolloff 8
- :sidescrolloff 8
- :colorcolumn :88
- :shortmess :filnxtToOFWIcC
- :spell true
- : spellfile
- :spelllang [:en_us]
- ;; the font used in graphical neovim applications
- :guifont "monospace:h17"
- :splitkeep :screen
- :inccommand :split
- :winborder :single
- :shada ["'10" :<0 :s10 :h]})
+(local spellfile (.. (os.getenv :XDG_CONFIG_HOME) :/nvim/spell/en.utf-8.add))
-(each [k v (pairs opts)]
- (tset vim.opt k v))
+(set-opts {:backup false
+ :clipboard :unnamedplus
+ :cmdheight 1
+ :completeopt {:menuone :noselect}
+ :conceallevel 0
+ :fileencoding :utf-8
+ :hlsearch true
+ :ignorecase true
+ :mouse ""
+ :pumheight 10
+ :showmode false
+ :showtabline 0
+ :smartcase true
+ :smartindent true
+ :splitbelow true
+ :splitright true
+ :swapfile false
+ :termguicolors true
+ :timeoutlen 1000
+ :undofile true
+ :updatetime 1000
+ :writebackup false
+ :expandtab true
+ :shiftwidth 2
+ :tabstop 2
+ :cursorline true
+ :number true
+ :relativenumber true
+ :numberwidth 2
+ :signcolumn :yes
+ :wrap false
+ :laststatus 3
+ :autoread true
+ :scrolloff 8
+ :sidescrolloff 8
+ :colorcolumn :88
+ :shortmess :filnxtToOFWIcC
+ :spell true
+ : spellfile
+ :spelllang [:en_us]
+ :guifont "monospace:h17"
+ :splitkeep :screen
+ :inccommand :split
+ :winborder :single
+ :shada ["'10" :<0 :s10 :h]})
(vim.opt.jumpoptions:append :stack)
diff --git a/fnl/util/cmds.fnl b/fnl/util/cmds.fnl
deleted file mode 100644
index 5881634..0000000
--- a/fnl/util/cmds.fnl
+++ /dev/null
@@ -1,11 +0,0 @@
-(λ 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))))
-
-(λ create-auto-cmds [auto-cmds]
- (each [_ auto-cmd (ipairs auto-cmds)]
- (match auto-cmd
- [event opts] (vim.api.nvim_create_autocmd event opts))))
-
-{: create-user-cmds : create-auto-cmds}
diff --git a/fnl/util/load.fnl b/fnl/util/load.fnl
deleted file mode 100644
index afc6cf1..0000000
--- a/fnl/util/load.fnl
+++ /dev/null
@@ -1,8 +0,0 @@
-;; Load file with function
-
-(λ apply-to-files [path f]
- (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) path))]
- (when (= type :file)
- (f (fname:match "^(.*)%.fnl$")))))
-
-{: apply-to-files}