From 8d8cf86821d7cc1b093d149389baf5272e8033ca Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Fri, 13 Jan 2023 01:35:12 +0100 Subject: Refactor settings and plugins --- fnl/plugins/init.fnl | 25 +++++++++++-------- fnl/plugins/lazy.fnl | 58 +++++++++++++++++++++++++-------------------- fnl/plugins/lir.fnl | 2 +- fnl/plugins/lsp/keymaps.fnl | 36 +++++++++++++--------------- 4 files changed, 65 insertions(+), 56 deletions(-) (limited to 'fnl/plugins') 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 : 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 - "lua vim.lsp.buf.declaration()" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gd - "lua vim.lsp.buf.definition()" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gI - "lua vim.lsp.buf.implementation()" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gr - "lua vim.lsp.buf.references()" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gl - "lua vim.diagnostic.open_float()" - opts) - (vim.api.nvim_buf_set_keymap bufnr :n :gs - "lua vim.lsp.buf.signature_help()" - opts))) +(local opts {:noremap true :silent true}) + +(local mappings + [[:n :gD "lua vim.lsp.buf.declaration()"] + [:n :gd "lua vim.lsp.buf.definition()"] + [:n :gI "lua vim.lsp.buf.implementation()"] + [:n :gr "lua vim.lsp.buf.references()"] + [:n :gl "lua vim.diagnostic.open_float()"] + [:n :gs "lua vim.lsp.buf.signature_help()"]]) + +(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} -- cgit v1.2.3-70-g09d2