From d23440203c2507574d7f611533b12533c46dc9b7 Mon Sep 17 00:00:00 2001 From: Fernando Araoz Date: Thu, 23 Jan 2025 22:44:48 -0500 Subject: [PATCH] feat(nvim): continue fennel rewrite pt2 --- config/nvim/fnl/plugins/barbecue.fnl | 8 +++ config/nvim/fnl/plugins/cokeline.fnl | 66 ++++++++++++++++++++++ config/nvim/fnl/plugins/editor.fnl | 84 ++++++++++++++++++++++++++++ config/nvim/fnl/plugins/whichkey.fnl | 41 ++++++++++++++ 4 files changed, 199 insertions(+) create mode 100644 config/nvim/fnl/plugins/barbecue.fnl create mode 100644 config/nvim/fnl/plugins/cokeline.fnl create mode 100644 config/nvim/fnl/plugins/whichkey.fnl diff --git a/config/nvim/fnl/plugins/barbecue.fnl b/config/nvim/fnl/plugins/barbecue.fnl new file mode 100644 index 0000000..e13cc45 --- /dev/null +++ b/config/nvim/fnl/plugins/barbecue.fnl @@ -0,0 +1,8 @@ +(local barbecue {1 :utilyre/barbecue.nvim + :dependencies [:SmiteshP/nvim-navic + :nvim-tree/nvim-web-devicons] + :name :barbecue + :opts {} + :version "*"}) + +[barbecue] diff --git a/config/nvim/fnl/plugins/cokeline.fnl b/config/nvim/fnl/plugins/cokeline.fnl new file mode 100644 index 0000000..af316a0 --- /dev/null +++ b/config/nvim/fnl/plugins/cokeline.fnl @@ -0,0 +1,66 @@ +(local cokeline {1 :willothy/nvim-cokeline + :config (fn [] + (local get-hex + (. (require :cokeline.hlgroups) :get_hl_attr)) + (local hlgroups (require :cokeline.hlgroups)) + (local yellow vim.g.terminal_color_3) + ((. (require :cokeline) :setup) {:components [{:text (fn [buffer] + (.. " " + buffer.index))} + {:fg (fn [buffer] + buffer.devicon.color) + :text (fn [buffer] + (.. " " + buffer.devicon.icon))} + {:fg (fn [] + (hlgroups.get_hl_attr :Comment + :fg)) + :italic true + :text (fn [buffer] + buffer.unique_prefix)} + {:text (fn [buffer] + buffer.filename) + :underline (fn [buffer] + (when (and buffer.is_hovered + (not buffer.is_focused)) + true))} + {:text " "} + {:on_click (fn [_ + _ + _ + _ + buffer] + (buffer:delete)) + :text (fn [buffer] + (when buffer.is_modified + (lua "return \"\"")) + (when buffer.is_hovered + (lua "return \"󰅙\"")) + "󰅖")} + {:text " "}] + :default_hl {:bg (fn [buffer] + (or (and buffer.is_focused + (get-hex :Normal + :fg)) + (get-hex :ColorColumn + :bg))) + :fg (fn [buffer] + (or (and buffer.is_focused + (get-hex :ColorColumn + :bg)) + (get-hex :Normal + :fg)))} + :sidebar {:components [{:bg (fn [] + (get-hex :NvimTreeNormal + :bg)) + :bold true + :fg yellow + :text (fn [buf] + buf.filetype)}] + :filetype [:NvimTree + :neo-tree]}})) + :dependencies [:nvim-lua/plenary.nvim + :nvim-tree/nvim-web-devicons + :stevearc/resession.nvim]}) + +[cokeline] diff --git a/config/nvim/fnl/plugins/editor.fnl b/config/nvim/fnl/plugins/editor.fnl index fec3a49..2468629 100644 --- a/config/nvim/fnl/plugins/editor.fnl +++ b/config/nvim/fnl/plugins/editor.fnl @@ -11,7 +11,91 @@ (. (require :nvim-emmet) :wrap_with_abbreviation)))}) +(local autoformat {1 :stevearc/conform.nvim + :cmd [:ConformInfo] + :event [:BufWritePre] + :keys [{1 :f + 2 (fn [] + ((. (require :conform) :format) {:async true + :lsp_format :fallback})) + :desc "[F]ormat buffer" + :mode ""}] + :opts {:format_on_save (fn [bufnr] + (local disable-filetypes + {:c true :cpp true}) + (var lsp-format-opt nil) + (if (. disable-filetypes + (. vim.bo bufnr :filetype)) + (set lsp-format-opt :never) + (set lsp-format-opt :fallback)) + {:lsp_format lsp-format-opt + :timeout_ms 500}) + :formatters_by_ft {:lua [:stylua]} + :notify_on_error false}}) + +(local autocomplete {1 :hrsh7th/nvim-cmp + :config (fn [] + (local cmp (require :cmp)) + (local luasnip (require :luasnip)) + (luasnip.config.setup {}) + (cmp.setup {:completion {:completeopt "menu,menuone,noinsert"} + :mapping (cmp.mapping.preset.insert {: (cmp.mapping.complete {}) + : (cmp.mapping.scroll_docs (- 4)) + : (cmp.mapping.scroll_docs 4) + : (cmp.mapping (fn [] + (when (luasnip.locally_jumpable (- 1)) + (luasnip.jump (- 1)))) + [:i + :s]) + : (cmp.mapping (fn [] + (when (luasnip.expand_or_locally_jumpable) + (luasnip.expand_or_jump))) + [:i + :s]) + : (cmp.mapping.select_next_item) + : (cmp.mapping.select_prev_item) + : (cmp.mapping.confirm {:select true})}) + :snippet {:expand (fn [args] + (luasnip.lsp_expand args.body))} + :sources [{:group_index 0 + :name :lazydev} + {:name :nvim_lsp} + {:name :luasnip} + {:name :path}]})) + :dependencies [{1 :L3MON4D3/LuaSnip + :build ((fn [] + (when (or (= (vim.fn.has :win32) + 1) + (= (vim.fn.executable :make) + 0)) + (lua "return ")) + "make install_jsregexp")) + :dependencies {}} + :saadparwaiz1/cmp_luasnip + :hrsh7th/cmp-nvim-lsp + :hrsh7th/cmp-path] + :event :InsertEnter}) + +(local comments {1 :folke/todo-comments.nvim + :dependencies [:nvim-lua/plenary.nvim] + :event :VimEnter + :opts {:signs false}}) + +(local mini {1 :echasnovski/mini.nvim + :config (fn [] + ((. (require :mini.ai) :setup) {:n_lines 500}) + ((. (require :mini.surround) :setup)) + (local statusline (require :mini.statusline)) + (statusline.setup {:use_icons vim.g.have_nerd_font}) + + (fn statusline.section_location [] + "%2l:%-2v"))}) + [ blankline emmet + autoformat + autocomplete + comments + mini ] diff --git a/config/nvim/fnl/plugins/whichkey.fnl b/config/nvim/fnl/plugins/whichkey.fnl new file mode 100644 index 0000000..c95d583 --- /dev/null +++ b/config/nvim/fnl/plugins/whichkey.fnl @@ -0,0 +1,41 @@ +(local whichkey + {1 :folke/which-key.nvim + :event :VimEnter + :opts {:icons {:keys (or (and vim.g.have_nerd_font {}) + {:BS " " + :C " " + :CR " " + :D " " + :Down " " + :Esc " " + :F1 : + :F10 : + :F11 : + :F12 : + :F2 : + :F3 : + :F4 : + :F5 : + :F6 : + :F7 : + :F8 : + :F9 : + :Left " " + :M " " + :NL " " + :Right " " + :S " " + :ScrollWheelDown " " + :ScrollWheelUp " " + :Space " " + :Tab " " + :Up " "}) + :mappings vim.g.have_nerd_font} + :spec [{1 :c :group "[C]ode" :mode [:n :x]} + {1 :d :group "[D]ocument"} + {1 :r :group "[R]ename"} + {1 :s :group "[S]earch"} + {1 :w :group "[W]orkspace"} + {1 :t :group "[T]oggle"}]}}) + +[whichkey]