summaryrefslogtreecommitdiff
path: root/fnl/plugins
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-13 01:35:12 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-13 01:35:12 +0100
commit8d8cf86821d7cc1b093d149389baf5272e8033ca (patch)
tree793346b35c1ce6c60e0f7ee96c7e9696c3a2a36d /fnl/plugins
parentac8af14d5137de52ce12f432d61b1c3f9f8c185b (diff)
Refactor settings and plugins
Diffstat (limited to 'fnl/plugins')
-rw-r--r--fnl/plugins/init.fnl25
-rw-r--r--fnl/plugins/lazy.fnl58
-rw-r--r--fnl/plugins/lir.fnl2
-rw-r--r--fnl/plugins/lsp/keymaps.fnl36
4 files changed, 65 insertions, 56 deletions
diff --git a/fnl/plugins/init.fnl b/fnl/plugins/init.fnl
index d767506..6b0bde8 100644
--- a/fnl/plugins/init.fnl
+++ b/fnl/plugins/init.fnl
@@ -1,11 +1,16 @@
-;; Returns a list of all plugins.
+;; Load all plugins.
-(let [plugins (require :plugins.lsp)
- path (.. (vim.fn.stdpath :config) :/fnl/plugins)]
- (if (vim.loop.fs_stat path)
- (do
- (each [fname (vim.fs.dir path)]
- (let [fname (fname:match "^(.*)%.fnl$")]
- (if (and (not= fname nil) (not= fname :init) (not= fname :lazy))
- (table.insert plugins (require (.. :plugins. fname))))))))
- plugins)
+(local plugins (let [plugins (require :plugins.lsp)
+ path (.. (vim.fn.stdpath :config) :/fnl/plugins)]
+ (if (vim.loop.fs_stat path)
+ (do
+ (each [fname (vim.fs.dir path)]
+ (let [fname (fname:match "^(.*)%.fnl$")]
+ (if (and (not= fname nil) (not= fname :init)
+ (not= fname :lazy))
+ (table.insert plugins
+ (require (.. :plugins. fname))))))))
+ plugins))
+
+(let [lazy (require :plugins.lazy)]
+ (lazy.setup plugins))
diff --git a/fnl/plugins/lazy.fnl b/fnl/plugins/lazy.fnl
index 25e374b..9c28a95 100644
--- a/fnl/plugins/lazy.fnl
+++ b/fnl/plugins/lazy.fnl
@@ -1,28 +1,34 @@
;; Lazy opts.
-{:install {:colorscheme [:no-clown-fiesta]}
- :performance {:cache {:enabled true}
- :rtp {:disabled_plugins [:gzip
- :matchit
- :matchparen
- :netrwPlugin
- :tarPlugin
- :tohtml
- :tutor
- :zipPlugin]}}
- :ui {:icons {:cmd " "
- :config " "
- :event " "
- :ft " "
- :init " "
- :import " "
- :keys " "
- :lazy "鈴 "
- :loaded "● "
- :not_loaded "○ "
- :plugin " "
- :runtime " "
- :source " "
- :start " "
- :task " "
- :list ["● " " " " " "‒ "]}}}
+(local opts {:install {:colorscheme [:no-clown-fiesta]}
+ :performance {:cache {:enabled true}
+ :rtp {:disabled_plugins [:gzip
+ :matchit
+ :matchparen
+ :netrwPlugin
+ :tarPlugin
+ :tohtml
+ :tutor
+ :zipPlugin]}}
+ :ui {:icons {:cmd " "
+ :config " "
+ :event " "
+ :ft " "
+ :init " "
+ :import " "
+ :keys " "
+ :lazy "鈴 "
+ :loaded "● "
+ :not_loaded "○ "
+ :plugin " "
+ :runtime " "
+ :source " "
+ :start " "
+ :task " "
+ :list ["● " " " " " "‒ "]}}})
+
+(fn setup [plugins]
+ (let [lazy (require :lazy)]
+ (lazy.setup plugins opts)))
+
+{: setup}
diff --git a/fnl/plugins/lir.fnl b/fnl/plugins/lir.fnl
index b23d439..8caa8e4 100644
--- a/fnl/plugins/lir.fnl
+++ b/fnl/plugins/lir.fnl
@@ -2,7 +2,7 @@
(fn opts [actions mark-actions clipboard-actions]
{:show_hidden_files false
- :devicons_enable true
+ :devicons {:enable true :highlight_dirname false}
:mappings {:l actions.edit
:<C-s> actions.split
:v actions.vsplit
diff --git a/fnl/plugins/lsp/keymaps.fnl b/fnl/plugins/lsp/keymaps.fnl
index a7fac89..9b95140 100644
--- a/fnl/plugins/lsp/keymaps.fnl
+++ b/fnl/plugins/lsp/keymaps.fnl
@@ -1,23 +1,21 @@
;; Key mappings for lsp.
-(fn on-attach [bufnr] (let [opts {:noremap true :silent true}]
- (vim.api.nvim_buf_set_keymap bufnr :n :gD
- "<cmd>lua vim.lsp.buf.declaration()<CR>"
- opts)
- (vim.api.nvim_buf_set_keymap bufnr :n :gd
- "<cmd>lua vim.lsp.buf.definition()<CR>"
- opts)
- (vim.api.nvim_buf_set_keymap bufnr :n :gI
- "<cmd>lua vim.lsp.buf.implementation()<CR>"
- opts)
- (vim.api.nvim_buf_set_keymap bufnr :n :gr
- "<cmd>lua vim.lsp.buf.references()<CR>"
- opts)
- (vim.api.nvim_buf_set_keymap bufnr :n :gl
- "<cmd>lua vim.diagnostic.open_float()<CR>"
- opts)
- (vim.api.nvim_buf_set_keymap bufnr :n :gs
- "<cmd>lua vim.lsp.buf.signature_help()<CR>"
- opts)))
+(local opts {:noremap true :silent true})
+
+(local mappings
+ [[:n :gD "<cmd>lua vim.lsp.buf.declaration()<CR>"]
+ [:n :gd "<cmd>lua vim.lsp.buf.definition()<CR>"]
+ [:n :gI "<cmd>lua vim.lsp.buf.implementation()<CR>"]
+ [:n :gr "<cmd>lua vim.lsp.buf.references()<CR>"]
+ [:n :gl "<cmd>lua vim.diagnostic.open_float()<CR>"]
+ [:n :gs "<cmd>lua vim.lsp.buf.signature_help()<CR>"]])
+
+(fn buf-set-keymap [bufnr mode key cmd opts]
+ (vim.api.nvim_buf_set_keymap bufnr mode key cmd opts))
+
+(fn on-attach [bufnr]
+ (each [_ mapping (ipairs mappings)]
+ (match mapping
+ [mode key cmd] (buf-set-keymap bufnr mode key cmd opts))))
{: on-attach}