From 690986b32ef794e6c90d0a9eb8ff4c6768408f54 Mon Sep 17 00:00:00 2001 From: Fernando Araoz Date: Thu, 23 Jan 2025 22:24:06 -0500 Subject: [PATCH] feat(nvim): attempt rewrite with fennel --- config/nvim/fnl/config.fnl | 89 +++++++++++++++++++++++++++++++- config/nvim/fnl/plugins/init.fnl | 3 -- config/nvim/init.lua | 2 - config/river/init | 2 +- 4 files changed, 89 insertions(+), 7 deletions(-) delete mode 100644 config/nvim/fnl/plugins/init.fnl diff --git a/config/nvim/fnl/config.fnl b/config/nvim/fnl/config.fnl index 832838f..a09a26d 100644 --- a/config/nvim/fnl/config.fnl +++ b/config/nvim/fnl/config.fnl @@ -1,8 +1,95 @@ +; My Neovim config, based on kickstart.nvim +; and rewritten in Fennel, because why not? + (set vim.g.mapleader " ") (set vim.g.maplocalleader " ") (set vim.g.have_nerd_font true) (set vim.opt.number true) (set vim.opt.relativenumber true) +(set vim.opt.mouse "a") +(set vim.opt.showmode false) +(vim.schedule (fn [] (set vim.opt.clipboard "unnamedplus"))) +(set vim.opt.breakindent true) +(set vim.opt.undofile true) +(set vim.opt.ignorecase true) +(set vim.opt.smartcase true) +(set vim.opt.signcolumn "yes") +(set vim.opt.updatetime 250) +(set vim.opt.timeoutlen 300) +(set vim.opt.splitright true) +(set vim.opt.splitbelow true) +(set vim.opt.list true) +(set vim.opt.listchars + {"tab" "» " "trail" "·" "nbsp" "␣"}) +(set vim.opt.inccommand "split") +(set vim.opt.cursorline true) +; Minimal number of screen lines to keep above/below +(set vim.opt.scrolloff 4) -(print "I have been setup :D") +; +; Setup carry over +; +; Keymaps for buffer switching +(vim.keymap.set :n :h "(cokeline-focus-prev)" + {:desc "Previous buffer"}) +(vim.keymap.set :n :l "(cokeline-focus-next)" + {:desc "Next buffer"}) +(vim.keymap.set :n :a ":e #" {:desc "[A]lternate buffer"}) +(vim.keymap.set :n :bd ":bd" {:desc "[B]uffer [D]elete"}) + +; cokeline +(for [i 1 9] + (vim.keymap.set :n (: "%s" :format i) + (: "(cokeline-focus-%s)" :format i) + {:desc (: "Switch to tab %s" :format i) :silent true})) + +(vim.keymap.set :n :H "(cokeline-switch-prev)" + {:desc "Previous buffer swap"}) +(vim.keymap.set :n :L "(cokeline-switch-next)" + {:desc "Next buffer swap"}) + +; neotree +(vim.keymap.set :n :tn ":Neotree focus toggle" + {:desc "[T]oggle [N]eotree"}) +(vim.keymap.set :n :tr ":Neotree reveal" + {:desc "[T]oggle Neotree [R]eveal"}) +(vim.keymap.set :n :tg ":Telescope git_status" + {:desc "[T]elescope [G]it status"}) +(vim.keymap.set :n : :nohlsearch) +(vim.keymap.set :n :q vim.diagnostic.setloclist + {:desc "Open diagnostic [Q]uickfix list"}) + +; Moving +(vim.keymap.set :n : : {:desc "Move focus to the left window"}) +(vim.keymap.set :n : : {:desc "Move focus to the right window"}) +(vim.keymap.set :n : : {:desc "Move focus to the lower window"}) +(vim.keymap.set :n : : {:desc "Move focus to the upper window"}) + +; Fold +(vim.keymap.set :n :z$ "$zf%" {:desc "Fold EOL & %"}) + +; Highlight when yanking (copying) text +(vim.api.nvim_create_autocmd :TextYankPost + {:callback (fn [] (vim.highlight.on_yank)) + :desc "Highlight when yanking (copying) text" + :group (vim.api.nvim_create_augroup :kickstart-highlight-yank + {:clear true})}) + +(fn set-theme-for-directory [] + (let [cwd (vim.fn.getcwd) + directory-themes {:acide/trazo-backend :github_light + :acide/trazo-frontend :onelight + :csharp :caret + :zig :ayu-dark}] + (var theme :randomhue) + (each [dir dir-theme (pairs directory-themes)] + (when (string.find cwd dir 1 true) (set theme dir-theme) (lua :break))) + (vim.cmd (.. "colorscheme " theme)))) + +(vim.api.nvim_create_autocmd [:DirChanged] + {:callback (fn [] (set-theme-for-directory))}) + +(set-theme-for-directory) + +(print "I have been setup with Fennel :D") diff --git a/config/nvim/fnl/plugins/init.fnl b/config/nvim/fnl/plugins/init.fnl deleted file mode 100644 index 70e822c..0000000 --- a/config/nvim/fnl/plugins/init.fnl +++ /dev/null @@ -1,3 +0,0 @@ -(print ":D (happy) (fennel lazy module)") - -[] diff --git a/config/nvim/init.lua b/config/nvim/init.lua index eb14ff7..8297e5b 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -49,5 +49,3 @@ require("lazy").setup({ { import = "plugins" }, }, }) - - diff --git a/config/river/init b/config/river/init index 7888afa..7f9d1b6 100755 --- a/config/river/init +++ b/config/river/init @@ -51,7 +51,7 @@ riverctl map normal Super+Shift Comma send-to-output previous # focused window border riverctl border-width 4 -riverctl border-color-focused 0xc026d3ff +riverctl border-color-focused 0x581C87AA riverctl border-color-unfocused 0xff000000