From 64560eb91743a827c78d525858a0c43adef6f548 Mon Sep 17 00:00:00 2001 From: eltrac Date: Sun, 8 Nov 2026 21:01:41 +0800 Subject: nvim: convert nvim submodule to a tracked directory --- nvim | 1 - nvim/.nfnl.fnl | 1 + nvim/README.md | 31 ++++++++ nvim/convert-to-fennel.nu | 16 ++++ nvim/flsproject.fnl | 3 + nvim/fnl/config/lazy.fnl | 30 +++++++ nvim/fnl/filetype.fnl | 26 +++++++ nvim/fnl/plugins/blink.fnl | 10 +++ nvim/fnl/plugins/conjure.fnl | 2 + nvim/fnl/plugins/encrypt.fnl | 2 + nvim/fnl/plugins/flash-zh.fnl | 9 +++ nvim/fnl/plugins/flash.fnl | 4 + nvim/fnl/plugins/im-select.fnl | 4 + nvim/fnl/plugins/jieba.fnl | 5 ++ nvim/fnl/plugins/kanagawa.fnl | 8 ++ nvim/fnl/plugins/lazygit.fnl | 10 +++ nvim/fnl/plugins/lexima.fnl | 2 + nvim/fnl/plugins/lualine.fnl | 79 +++++++++++++++++++ nvim/fnl/plugins/markdown-plus.fnl | 6 ++ nvim/fnl/plugins/mason.fnl | 2 + nvim/fnl/plugins/nfnl.fnl | 2 + nvim/fnl/plugins/nvim-lspconfig.fnl | 48 ++++++++++++ nvim/fnl/plugins/nvim-telescope.fnl | 22 ++++++ nvim/fnl/plugins/nvim-toggler.fnl | 4 + nvim/fnl/plugins/nvim-treesitter.fnl | 20 +++++ nvim/fnl/plugins/oil.fnl | 7 ++ nvim/fnl/plugins/paredit.fnl | 4 + nvim/fnl/plugins/render-markdown.fnl | 4 + nvim/fnl/plugins/startup.fnl | 75 ++++++++++++++++++ nvim/fnl/plugins/vim-go.fnl | 15 ++++ nvim/fnl/plugins/wakatime.fnl | 4 + nvim/fnl/plugins/whichkey.fnl | 8 ++ nvim/fnl/plugins/wordcount.fnl | 2 + nvim/init.fnl | 63 +++++++++++++++ nvim/lazy-lock.json | 38 +++++++++ nvim/screenshot.png | Bin 0 -> 4349573 bytes nvim/script/fennel.bb | 147 +++++++++++++++++++++++++++++++++++ 37 files changed, 713 insertions(+), 1 deletion(-) delete mode 160000 nvim create mode 100644 nvim/.nfnl.fnl create mode 100644 nvim/README.md create mode 100644 nvim/convert-to-fennel.nu create mode 100644 nvim/flsproject.fnl create mode 100644 nvim/fnl/config/lazy.fnl create mode 100644 nvim/fnl/filetype.fnl create mode 100644 nvim/fnl/plugins/blink.fnl create mode 100644 nvim/fnl/plugins/conjure.fnl create mode 100644 nvim/fnl/plugins/encrypt.fnl create mode 100644 nvim/fnl/plugins/flash-zh.fnl create mode 100644 nvim/fnl/plugins/flash.fnl create mode 100644 nvim/fnl/plugins/im-select.fnl create mode 100644 nvim/fnl/plugins/jieba.fnl create mode 100644 nvim/fnl/plugins/kanagawa.fnl create mode 100644 nvim/fnl/plugins/lazygit.fnl create mode 100644 nvim/fnl/plugins/lexima.fnl create mode 100644 nvim/fnl/plugins/lualine.fnl create mode 100644 nvim/fnl/plugins/markdown-plus.fnl create mode 100644 nvim/fnl/plugins/mason.fnl create mode 100644 nvim/fnl/plugins/nfnl.fnl create mode 100644 nvim/fnl/plugins/nvim-lspconfig.fnl create mode 100644 nvim/fnl/plugins/nvim-telescope.fnl create mode 100644 nvim/fnl/plugins/nvim-toggler.fnl create mode 100644 nvim/fnl/plugins/nvim-treesitter.fnl create mode 100644 nvim/fnl/plugins/oil.fnl create mode 100644 nvim/fnl/plugins/paredit.fnl create mode 100644 nvim/fnl/plugins/render-markdown.fnl create mode 100644 nvim/fnl/plugins/startup.fnl create mode 100644 nvim/fnl/plugins/vim-go.fnl create mode 100644 nvim/fnl/plugins/wakatime.fnl create mode 100644 nvim/fnl/plugins/whichkey.fnl create mode 100644 nvim/fnl/plugins/wordcount.fnl create mode 100644 nvim/init.fnl create mode 100644 nvim/lazy-lock.json create mode 100644 nvim/screenshot.png create mode 100644 nvim/script/fennel.bb diff --git a/nvim b/nvim deleted file mode 160000 index d2e1e6a..0000000 --- a/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d2e1e6a0d60cf427a8a56c0caf57c8ec60a8e366 diff --git a/nvim/.nfnl.fnl b/nvim/.nfnl.fnl new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/nvim/.nfnl.fnl @@ -0,0 +1 @@ +{} diff --git a/nvim/README.md b/nvim/README.md new file mode 100644 index 0000000..3556609 --- /dev/null +++ b/nvim/README.md @@ -0,0 +1,31 @@ +![screenshot](screenshot.png) + +# `eltrac.nvim` + +Come and observe a clumsy koala tweaks his editor. + +## Setup + +This configuration uses [Fennel](https://fennel-lang.org/) over Lua. All `.fnl` files are compiled to `.lua` (instead of evaluating during runtime) out of consideration for performance and booting speed, using [nfnl](https://github.com/Olical/nfnl). + +When installing for the first time (nfnl was not available), run this command to compile all Fennel files to Lua. Make sure you have [Babashka](https://babashka.org/) installed. + +``` shell +bb script/fennel.bb --files | bb script/fennel.bb --compile +``` + +When nfnl is available, run `:NfnlCompileAllFiles` inside Neovim to compile all, or edit a `.fnl` file to compile this file upon every `:wq`. + +## Make your own Fennel-based configuration! + +There is a [Nushell](https://www.nushell.sh/) script (`convert-to-fennel.nu`) that converts `.lua` files to `.fnl` using [antifennel](https://git.sr.ht/~technomancy/antifennel). If you have a regular Lua-based Neovim configuration, do this and you will have a working Fennel-based one! + +Be sure to back up your configuration before running these scripts: + +```shell +nu convert-to-fennel.nu +bb script/fennel.bb --files | bb script/fennel.bb --compile +``` + +If you don't use Nushell or don't have antifennel installed, this script will not work. I'll try to make time and create a self-contained binary that does this... some day. + diff --git a/nvim/convert-to-fennel.nu b/nvim/convert-to-fennel.nu new file mode 100644 index 0000000..67a9886 --- /dev/null +++ b/nvim/convert-to-fennel.nu @@ -0,0 +1,16 @@ +def find-luas [dir] { + ls $dir | where name ends-with .lua | where type == "file" | get name +} + +let luas = find-luas . | append (find-luas ./lua) | append (find-luas ./lua/plugins/) | append (find-luas ./lua/config) + +$luas | each {|lua| + let fnl = $lua | str replace "lua\/" "fnl\/" | str replace ".lua" ".fnl" + try { + let filename = ls $fnl | get "name" + [$filename.0, " already converted"] | str join + } catch { + antifennel $lua | save $fnl + [$fnl, " now converted! ✅"] | str join + } +} diff --git a/nvim/flsproject.fnl b/nvim/flsproject.fnl new file mode 100644 index 0000000..a8cc96a --- /dev/null +++ b/nvim/flsproject.fnl @@ -0,0 +1,3 @@ +{:extra-globals ["vim"] + :libraries {:nvim true}} + diff --git a/nvim/fnl/config/lazy.fnl b/nvim/fnl/config/lazy.fnl new file mode 100644 index 0000000..c75302d --- /dev/null +++ b/nvim/fnl/config/lazy.fnl @@ -0,0 +1,30 @@ +(local lazypath (.. (vim.fn.stdpath :data) :/lazy/lazy.nvim)) + +(if (not ((. (or vim.uv vim.loop) :fs_stat) lazypath)) + (let [lazyrepo "https://github.com/folke/lazy.nvim.git" + out (vim.fn.system [:git + :clone + "--filter=blob:none" + :--branch=stable + lazyrepo + lazypath])] + (if (not= vim.v.shell_error 0) + (do + (vim.api.nvim_echo [["Failed to clone lazy.nvim:\n" :ErrorMsg] + [out :WarningMsg] + ["\nPress any key to exit..."]] + true {}) + (vim.fn.getchar) + (os.exit 1)) (do + ))) + (do + )) + +(vim.opt.rtp:prepend lazypath) + +((. (require :lazy) :setup) {:checker {:enabled true} + :install {:colorscheme [:habamax]} + :spec [{:import :plugins}]}) + +{:fennel-path :./lazy.lua} + diff --git a/nvim/fnl/filetype.fnl b/nvim/fnl/filetype.fnl new file mode 100644 index 0000000..1f89999 --- /dev/null +++ b/nvim/fnl/filetype.fnl @@ -0,0 +1,26 @@ +(local M {}) + +;; file type gohtmltmpl +(vim.api.nvim_create_autocmd + [:BufRead :BufNewFile] + {:callback (fn [args] + (when (not vim.g.go_loaded) + (local content + (vim.fn.readfile args.file + "" 50)) + (var has-template false) + (each [_ line (ipairs content)] + (when (or (line:match "{{.<>}}") + (line:match "{{.*}}")) + (set has-template true) + (lua :break))) + (when has-template + (tset (. vim.bo args.buf) + :filetype :gohtmltmpl)))) + :pattern [:*.html :*.tmpl :*.gohtml]}) + +(vim.filetype.add {:extension {:scm "scheme"}}) +(vim.filetype.add {:extension {:skr "scheme"}}) + +M + diff --git a/nvim/fnl/plugins/blink.fnl b/nvim/fnl/plugins/blink.fnl new file mode 100644 index 0000000..f1e034d --- /dev/null +++ b/nvim/fnl/plugins/blink.fnl @@ -0,0 +1,10 @@ +{1 :saghen/blink.cmp + :dependencies [:rafamadriz/friendly-snippets] + :opts {:appearance {:nerd_font_variant :mono} + :completion {:documentation {:auto_show false} + :ghost_text {:enabled true}} + :fuzzy {:implementation :prefer_rust_with_warning} + :keymap {:preset :enter} + :sources {:default [:lsp :path :snippets :buffer]}} + :opts_extend [:sources.default] + :version :1.*} diff --git a/nvim/fnl/plugins/conjure.fnl b/nvim/fnl/plugins/conjure.fnl new file mode 100644 index 0000000..8fb6630 --- /dev/null +++ b/nvim/fnl/plugins/conjure.fnl @@ -0,0 +1,2 @@ +[:Olical/conjure] + diff --git a/nvim/fnl/plugins/encrypt.fnl b/nvim/fnl/plugins/encrypt.fnl new file mode 100644 index 0000000..2a17f4f --- /dev/null +++ b/nvim/fnl/plugins/encrypt.fnl @@ -0,0 +1,2 @@ +{1 :elentok/encrypt.nvim :opts {}} + diff --git a/nvim/fnl/plugins/flash-zh.fnl b/nvim/fnl/plugins/flash-zh.fnl new file mode 100644 index 0000000..b745d64 --- /dev/null +++ b/nvim/fnl/plugins/flash-zh.fnl @@ -0,0 +1,9 @@ +{1 :rainzm/flash-zh.nvim + :dependencies :folke/flash.nvim + :event :VeryLazy + :keys [{1 :s + 2 (fn [] + ((. (require :flash-zh) :jump) {:chinese_only false})) + :desc "Flash between Chinese" + :mode [:n :x :o]}]} + diff --git a/nvim/fnl/plugins/flash.fnl b/nvim/fnl/plugins/flash.fnl new file mode 100644 index 0000000..3acae81 --- /dev/null +++ b/nvim/fnl/plugins/flash.fnl @@ -0,0 +1,4 @@ +{1 :folke/flash.nvim + :event :VeryLazy + :opts {:modes {:char {:enabled false}} + :remote_op {:motion true :restore true}}} diff --git a/nvim/fnl/plugins/im-select.fnl b/nvim/fnl/plugins/im-select.fnl new file mode 100644 index 0000000..e26c2ac --- /dev/null +++ b/nvim/fnl/plugins/im-select.fnl @@ -0,0 +1,4 @@ +{1 :keaising/im-select.nvim + :config (fn [] + ((. (require :im_select) :setup) {:default_command :macism}))} + diff --git a/nvim/fnl/plugins/jieba.fnl b/nvim/fnl/plugins/jieba.fnl new file mode 100644 index 0000000..99620a4 --- /dev/null +++ b/nvim/fnl/plugins/jieba.fnl @@ -0,0 +1,5 @@ +[[:tpope/vim-repeat] + {1 :kkew3/jieba.vim + :branch :release + :build ":call jieba_vim#install()" + :init (fn [] (set vim.g.jieba_vim_lazy 1) (set vim.g.jieba_vim_keymap 1))}] diff --git a/nvim/fnl/plugins/kanagawa.fnl b/nvim/fnl/plugins/kanagawa.fnl new file mode 100644 index 0000000..e77e447 --- /dev/null +++ b/nvim/fnl/plugins/kanagawa.fnl @@ -0,0 +1,8 @@ +{1 :rebelot/kanagawa.nvim + :config (fn [] + ((. (require :kanagawa) :setup) + {:compile true + :theme :dragon}) + (vim.cmd "colorscheme kanagawa-dragon")) + :lazy false} + diff --git a/nvim/fnl/plugins/lazygit.fnl b/nvim/fnl/plugins/lazygit.fnl new file mode 100644 index 0000000..f89719f --- /dev/null +++ b/nvim/fnl/plugins/lazygit.fnl @@ -0,0 +1,10 @@ +{1 :kdheepak/lazygit.nvim + :cmd [:LazyGit + :LazyGitConfig + :LazyGitCurrentFile + :LazyGitFilter + :LazyGitFilterCurrentFile] + :dependencies [:nvim-lua/plenary.nvim] + :keys [{1 :lg 2 :LazyGit :desc :LazyGit}] + :lazy true} + diff --git a/nvim/fnl/plugins/lexima.fnl b/nvim/fnl/plugins/lexima.fnl new file mode 100644 index 0000000..45bcbdc --- /dev/null +++ b/nvim/fnl/plugins/lexima.fnl @@ -0,0 +1,2 @@ +{1 :cohama/lexima.vim :config (fn [])} + diff --git a/nvim/fnl/plugins/lualine.fnl b/nvim/fnl/plugins/lualine.fnl new file mode 100644 index 0000000..2da54aa --- /dev/null +++ b/nvim/fnl/plugins/lualine.fnl @@ -0,0 +1,79 @@ +{1 :nvim-lualine/lualine.nvim + :config (fn [] + ;; THEME + (fn kanagawa-lualine-theme [] + (var colors nil) + (set colors + ((. (require :kanagawa.colors) :setup) {:theme :dragon})) + (local palette colors.palette) + {:command {:a {:bg palette.dragonOrange + :fg palette.dragonBlack0 + :gui :bold} + :b {:bg palette.dragonBlack4 + :fg palette.dragonWhite} + :c {:bg palette.dragonBlack0 + :fg palette.dragonWhite}} + :inactive {:a {:bg palette.dragonBlack2 + :fg palette.dragonBlack6} + :b {:bg palette.dragonBlack2 + :fg palette.dragonBlack6} + :c {:bg palette.dragonBlack0 + :fg palette.dragonBlack6}} + :insert {:a {:bg palette.dragonGreen + :fg palette.dragonBlack0 + :gui :bold} + :b {:bg palette.dragonBlack4 + :fg palette.dragonWhite} + :c {:bg palette.dragonBlack0 + :fg palette.dragonWhite}} + :normal {:a {:bg palette.dragonBlue2 + :fg palette.dragonBlack0 + :gui :bold} + :b {:bg palette.dragonBlack4 + :fg palette.dragonWhite} + :c {:bg palette.dragonBlack0 + :fg palette.dragonWhite}} + :replace {:a {:bg palette.dragonRed + :fg palette.dragonBlack0 + :gui :bold} + :b {:bg palette.dragonBlack4 + :fg palette.dragonWhite} + :c {:bg palette.dragonBlack0 + :fg palette.dragonWhite}} + :visual {:a {:bg palette.dragonViolet + :fg palette.dragonBlack0 + :gui :bold} + :b {:bg palette.dragonBlack4 + :fg palette.dragonWhite} + :c {:bg palette.dragonBlack0 + :fg palette.dragonWhite}}}) + + ;; Custom components + (fn wordcount [] + (.. + "W:" + (: (require :wordcounter) :count_cur_buf_words))) + + ((. (require :lualine) :setup) {:inactive_sections {:lualine_a {} + :lualine_b {} + :lualine_c [:filename] + :lualine_x [:location] + :lualine_y {} + :lualine_z {}} + :options {:component_separators {:left "" + :right ""} + :section_separators {:left "" + :right ""} + :theme (kanagawa-lualine-theme)} + :sections {:lualine_a [:mode] + :lualine_b [:branch + :diff + :diagnostics] + :lualine_c [:filename] + :lualine_x [wordcount + :fileformat + :filetype] + :lualine_y [:progress] + :lualine_z [:location]}})) + :dependencies [:nvim-tree/nvim-web-devicons :rebelot/kanagawa.nvim]} + diff --git a/nvim/fnl/plugins/markdown-plus.fnl b/nvim/fnl/plugins/markdown-plus.fnl new file mode 100644 index 0000000..c5636d8 --- /dev/null +++ b/nvim/fnl/plugins/markdown-plus.fnl @@ -0,0 +1,6 @@ +{1 :yousefhadder/markdown-plus.nvim + :version :v2.1.0 + :ft :markdown + :opts {:keymaps {:enabled true} + :table {:keymaps {:enabled true}}}} + diff --git a/nvim/fnl/plugins/mason.fnl b/nvim/fnl/plugins/mason.fnl new file mode 100644 index 0000000..a4f86e7 --- /dev/null +++ b/nvim/fnl/plugins/mason.fnl @@ -0,0 +1,2 @@ +{1 :mason-org/mason.nvim :opts {}} + diff --git a/nvim/fnl/plugins/nfnl.fnl b/nvim/fnl/plugins/nfnl.fnl new file mode 100644 index 0000000..ca8ef2b --- /dev/null +++ b/nvim/fnl/plugins/nfnl.fnl @@ -0,0 +1,2 @@ +[:Olical/nfnl] + diff --git a/nvim/fnl/plugins/nvim-lspconfig.fnl b/nvim/fnl/plugins/nvim-lspconfig.fnl new file mode 100644 index 0000000..1c38cf3 --- /dev/null +++ b/nvim/fnl/plugins/nvim-lspconfig.fnl @@ -0,0 +1,48 @@ +[{1 :neovim/nvim-lspconfig + :config (fn [] + (local lsps [:gopls + :marksman + :ts_ls + :vue_ls + :cssls + :html + :unocss + :clojure_lsp + :ruff + :ty + :tinymist + :fennel_ls + :ltex]) + ((. (require :mason-lspconfig) :setup) {:ensure_installed lsps}) + (vim.lsp.config :lua_ls + {:settings {:Lua {:diagnostics {:globals [:vim]}}}}) + (local vue-language-server-path + (.. (vim.fn.expand :$MASON/packages) :/vue-language-server + "/node_modules/@vue/language-server")) + (local tsserver-filetypes + [:typescript + :javascript + :javascriptreact + :typescriptreact + :vue]) + (local vue-plugin + {:configNamespace :typescript + :languages [:vue] + :location vue-language-server-path + :name "@vue/typescript-plugin"}) + (local ts-ls-config + {:filetypes tsserver-filetypes + :init_options {:plugins [vue-plugin]}}) + (local vue-ls-config {}) + (local ltex-ls-config + {:settings {:ltex {:dictionary {:en-US [:Neovim :LSP :ltex-ls :Lua] + :zh-CN [:Neovim :LSP :ltex-ls :Lua]} + :disabledRules {:zh-CN [:EN_QUOTES]} + :language :zh-CN}}}) + (vim.lsp.config :vue_ls vue-ls-config) + (vim.lsp.config :ts_ls ts-ls-config) + (vim.lsp.config :ltex ltex-ls-config) + (vim.lsp.enable lsps)) + :dependencies [:mason-org/mason.nvim + :mason-org/mason-lspconfig.nvim]}] + diff --git a/nvim/fnl/plugins/nvim-telescope.fnl b/nvim/fnl/plugins/nvim-telescope.fnl new file mode 100644 index 0000000..fcefefd --- /dev/null +++ b/nvim/fnl/plugins/nvim-telescope.fnl @@ -0,0 +1,22 @@ +{1 :nvim-telescope/telescope.nvim + :dependencies [:nvim-lua/plenary.nvim + {1 :nvim-telescope/telescope-fzf-native.nvim :build :make}] + :opts (fn [_ opts] (local builtin (require :telescope.builtin)) + (vim.keymap.set :n :ff builtin.find_files + {:desc "Telescope find files"}) + (vim.keymap.set :n :fg builtin.live_grep + {:desc "Telescope live grep"}) + (vim.keymap.set :n :fb builtin.buffers + {:desc "Telescope buffers"}) + (vim.keymap.set :n :fh builtin.help_tags + {:desc "Telescope help tags"}) + (vim.keymap.set :n :fc builtin.commands + {:desc "Telescope commands"}) + (vim.keymap.set :n :fd builtin.lsp_document_symbols + {:desc "Telescope LSP symbols in current buffer."}) + (vim.keymap.set :n :fr builtin.lsp_references + {:desc "Telescope LSP references"}) + (vim.keymap.set :n :fs builtin.lsp_workspace_symbols + {:desc "Telescope LSP symbols in current workspace."})) + :version "*"} + diff --git a/nvim/fnl/plugins/nvim-toggler.fnl b/nvim/fnl/plugins/nvim-toggler.fnl new file mode 100644 index 0000000..031f0c9 --- /dev/null +++ b/nvim/fnl/plugins/nvim-toggler.fnl @@ -0,0 +1,4 @@ +{1 :nguyenvukhang/nvim-toggler + :opts (fn [_ opts] + ((. (require :nvim-toggler) :setup)))} + diff --git a/nvim/fnl/plugins/nvim-treesitter.fnl b/nvim/fnl/plugins/nvim-treesitter.fnl new file mode 100644 index 0000000..fbdd85f --- /dev/null +++ b/nvim/fnl/plugins/nvim-treesitter.fnl @@ -0,0 +1,20 @@ +{1 :nvim-treesitter/nvim-treesitter + :build ":TSUpdate" + :config (fn [] + ((. (require :nvim-treesitter) :setup)) + ((. (require :nvim-treesitter) :install) [:javascript + :html + :css + :go + :clojure + :gitignore + :gotmpl + :markdown + :lua + :python + :typst + :fennel + :scheme + :commonlisp])) + :lazy false} + diff --git a/nvim/fnl/plugins/oil.fnl b/nvim/fnl/plugins/oil.fnl new file mode 100644 index 0000000..4af1a5f --- /dev/null +++ b/nvim/fnl/plugins/oil.fnl @@ -0,0 +1,7 @@ +{1 :stevearc/oil.nvim + :config (fn [] + ((. (require :oil) :setup))) + :dependencies [{1 :nvim-mini/mini.icons :opts {}}] + :lazy false + :opts {}} + diff --git a/nvim/fnl/plugins/paredit.fnl b/nvim/fnl/plugins/paredit.fnl new file mode 100644 index 0000000..88d643a --- /dev/null +++ b/nvim/fnl/plugins/paredit.fnl @@ -0,0 +1,4 @@ +{1 :julienvincent/nvim-paredit + :config (fn [] + ((. (require :nvim-paredit) :setup)))} + diff --git a/nvim/fnl/plugins/render-markdown.fnl b/nvim/fnl/plugins/render-markdown.fnl new file mode 100644 index 0000000..a918a15 --- /dev/null +++ b/nvim/fnl/plugins/render-markdown.fnl @@ -0,0 +1,4 @@ +{1 :MeanderingProgrammer/render-markdown.nvim + :dependencies [:nvim-treesitter/nvim-treesitter :nvim-tree/nvim-web-devicons] + :opts {}} + diff --git a/nvim/fnl/plugins/startup.fnl b/nvim/fnl/plugins/startup.fnl new file mode 100644 index 0000000..cab3513 --- /dev/null +++ b/nvim/fnl/plugins/startup.fnl @@ -0,0 +1,75 @@ +{1 :startup-nvim/startup.nvim + :config (fn [] + ((. (require :startup) :setup) {:body {:align :center + :content [[" Find File" + "Telescope find_files" + :ff] + ["󰍉 Find Word" + "Telescope live_grep" + :lg] + [" Recent Files" + "Telescope oldfiles" + :of] + [" File Browser" + "Telescope file_browser" + :fb] + [" New File" + "lua require'startup'.new_file()" + :nf]] + :default_color "" + :fold_section false + :highlight :String + :margin 5 + :oldfiles_amount 0 + :oldfiles_directory false + :title "Basic Commands" + :type :mapping} + :colors {:background "#1f2227" + :folded_section "#56b6c2"} + :footer {:align :center + :content [:eltrac.nvim] + :default_color "" + :fold_section false + :highlight :Number + :margin 5 + :oldfiles_amount 0 + :oldfiles_directory false + :title :Footer + :type :text} + :header {:align :center + :content [" " + " " + " ,-. _,---._ __ / \\ " + " / ) .-' `./ / \\ " + "( ( ,' `/ /|" + " \\ `-\" \\'\\ / |" + " `. , \\ \\ / |" + " /`. ,'-`----Y |" + " ( ; | '" + " | ,-. ,-' | / " + " | | ( | | / " + " ) | \\ `.___________|/ " + " `--' `--' "] + :default_color "" + :fold_section false + :highlight :Statement + :margin 5 + :oldfiles_amount 0 + :oldfiles_directory false + :title :Header + :type :text} + :mappings {:execute_command : + :open_file :o + :open_file_split : + :open_help "?" + :open_section :} + :options {:cursor_column 0.5 + :disable_statuslines true + :empty_lines_between_mappings true + :mapping_keys true + :paddings [1 3 3 0]} + :parts [:header :body :footer]})) + :dependencies [:nvim-telescope/telescope.nvim + :nvim-lua/plenary.nvim + :nvim-telescope/telescope-file-browser.nvim]} + diff --git a/nvim/fnl/plugins/vim-go.fnl b/nvim/fnl/plugins/vim-go.fnl new file mode 100644 index 0000000..caa8693 --- /dev/null +++ b/nvim/fnl/plugins/vim-go.fnl @@ -0,0 +1,15 @@ +{1 :fatih/vim-go + :build ":GoUpdateBinaries" + :config (fn [] (set vim.g.go_fmt_command :goimports) + (set vim.g.go_metalinter_enabled [:vet :golint :errcheck]) + (set vim.g.go_metalinter_autosave 1) + (set vim.g.go_doc_keywordprg_enabled 0) + (set vim.g.go_def_mapping_enabled 0) + (set vim.g.go_code_completion_enabled 0) + (set vim.g.go_template_syntax 1) + (set vim.g.go_template_use_html 1) + (vim.keymap.set :n :gr :GoRun {:desc "Go Run"}) + (vim.keymap.set :n :gb :GoBuild {:desc "Go Build"}) + (vim.keymap.set :n :gt :GoTest {:desc "Go Test"})) + :ft [:go :gohtmltmpl :gotexttmpl :gomod :gowork]} + diff --git a/nvim/fnl/plugins/wakatime.fnl b/nvim/fnl/plugins/wakatime.fnl new file mode 100644 index 0000000..f1598a0 --- /dev/null +++ b/nvim/fnl/plugins/wakatime.fnl @@ -0,0 +1,4 @@ +(set vim.env.WAKATIME_HOME (.. (or vim.env.XDG_CONFIG_HOME (.. (vim.fn.expand "~") "/.config")) "/wakatime")) + +{1 :wakatime/vim-wakatime :lazy false} + diff --git a/nvim/fnl/plugins/whichkey.fnl b/nvim/fnl/plugins/whichkey.fnl new file mode 100644 index 0000000..be82820 --- /dev/null +++ b/nvim/fnl/plugins/whichkey.fnl @@ -0,0 +1,8 @@ +{1 :folke/which-key.nvim + :event :VeryLazy + :keys [{1 :? + 2 (fn [] + ((. (require :which-key) :show) {:global false})) + :desc "Buffer Local Keymaps (which-key)"}] + :opts {}} + diff --git a/nvim/fnl/plugins/wordcount.fnl b/nvim/fnl/plugins/wordcount.fnl new file mode 100644 index 0000000..0035c77 --- /dev/null +++ b/nvim/fnl/plugins/wordcount.fnl @@ -0,0 +1,2 @@ +{1 :npc-z/wordcounter.nvim + :dependencies :uga-rosa/utf8.nvim} diff --git a/nvim/init.fnl b/nvim/init.fnl new file mode 100644 index 0000000..d4b2f73 --- /dev/null +++ b/nvim/init.fnl @@ -0,0 +1,63 @@ +(macro conf [...] + (let [bindings [...] + result []] + (for [i 1 (length bindings) 2] + (let [k (. bindings i) + v (. bindings (+ i 1))] + (table.insert result `(set ,k ,v)))) + `(do ,(unpack result)))) + +(conf vim.g.mapleader " " + vim.g.maplocalleader "\\" + ;; disable built-in tree + vim.g.loaded_netrw 1 + vim.g.loaded_netrwPlugin 1 + ;; enable true color + vim.opt.termguicolors true + ;; show line numbers + vim.o.number true + ;; ensure new line at EOF + vim.opt.endofline true + vim.opt.fixendofline true + ;; tab width + vim.opt.tabstop 4 + vim.opt.shiftwidth 4 + vim.opt.expandtab true + ;; disable providers + vim.g.loaded_perl_provider 0 + vim.g.loaded_ruby_provider 0) + +;; cursorline +(vim.cmd "set cursorline") + +;; Show diagnostics +(vim.diagnostic.config {:virtual_text true + :signs true + :underline true + :update_in_insert false}) + +;; Escape TERMINAL mode using ESC +(vim.api.nvim_set_keymap + "t" "" "" { "desc" "Exit terminal mode" }) + +;; tab management +(vim.api.nvim_set_keymap + "n" "t" ":tabnew" { "desc" "create new tab" }) +(vim.api.nvim_set_keymap + "n" "T" ":tabn" { "desc" "jump to new tab" }) +(vim.api.nvim_set_keymap + "n" "X" ":tabclose" { "desc" "close current tab, like Vimium" }) + +; use custom file type +(require "filetype") + +;; Use Paredit +(vim.api.nvim_create_autocmd + "FileType" {"pattern" ["clojure" "fennel" "guile" "scheme" "scheme.guile" "lisp"] + "callback" (lambda [] (vim.treesitter.start))}) + +;; use lazy.nvim plugin manager +(require "config.lazy") + +{:fennel-path "./init.lua"} + diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json new file mode 100644 index 0000000..028dff9 --- /dev/null +++ b/nvim/lazy-lock.json @@ -0,0 +1,38 @@ +{ + "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, + "conjure": { "branch": "main", "commit": "b23c76a8c874fe7ac5ad95255efc66173b049088" }, + "encrypt.nvim": { "branch": "main", "commit": "363e1d924c6235ae4e9170b1e2ebab50a2e26c07" }, + "flash-zh.nvim": { "branch": "main", "commit": "5848840b5640e4688ac77aaf1d9dc71b68071f72" }, + "flash.nvim": { "branch": "main", "commit": "5f0f270fdc7c5b0c21d903ee85b9cb06f2ac636a" }, + "friendly-snippets": { "branch": "main", "commit": "b2ea5c41a150ba72fb656eedb4ed0a86d138d945" }, + "im-select.nvim": { "branch": "master", "commit": "963a4e9d528ef8a8d328eeff690593b0146d30e2" }, + "jieba.vim": { "branch": "release", "commit": "a8682dce052b2f689d5786c940d04a913d58c29e" }, + "kanagawa.nvim": { "branch": "master", "commit": "bb85e4bfc8d89b0e62c8fa53ccdd13d12e2f77b3" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazygit.nvim": { "branch": "main", "commit": "9ffc6103926718f7070fb4017694543cd7dc9718" }, + "lexima.vim": { "branch": "master", "commit": "9f6942c5e1f0f6fe63bdcdac515f34c484b970f5" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, + "markdown-plus.nvim": { "branch": "main", "commit": "98643a59b400eb2f1000589d7c221dcf99d08d9f" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3a5cd6d562a01f6829a35ae761dc383264ea452b" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, + "mini.icons": { "branch": "main", "commit": "eab3e692d796d78ea6ffc978d8a380ff26fcf4e3" }, + "nfnl": { "branch": "main", "commit": "7a4ba217167fee57e9bf175405636ced49aa9f83" }, + "nvim-lspconfig": { "branch": "master", "commit": "d5c7e7bcc15bccc01bf1601a03473e10de2f0f7e" }, + "nvim-paredit": { "branch": "master", "commit": "b6ba636874a3115d944e35746444724240568aca" }, + "nvim-toggler": { "branch": "main", "commit": "467808600882fd6c9e33b9dbc4889b1b80cfd917" }, + "nvim-treesitter": { "branch": "main", "commit": "915f2bd3d4e2a33704bfc476b5137e9befa82f3d" }, + "nvim-web-devicons": { "branch": "master", "commit": "0dc0cfb0c6858041174a53c7aa4adaf65e994b3c" }, + "oil.nvim": { "branch": "master", "commit": "d3733d933833a0e59b813ecec99341527adf0c28" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "render-markdown.nvim": { "branch": "main", "commit": "8e8795368391036643b622875a6da6a51bcd33f4" }, + "startup.nvim": { "branch": "master", "commit": "bd835f4fd95dbb30cb4607a8d7a090216fb6d035" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "3610dc7dc91f06aa98b11dca5cc30dfa98626b7e" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "b25b749b9db64d375d782094e2b9dce53ad53a40" }, + "telescope.nvim": { "branch": "master", "commit": "5255aa27c422de944791318024167ad5d40aad20" }, + "utf8.nvim": { "branch": "main", "commit": "954cbbadabe5cd19f202e918fec191d64eea7766" }, + "vim-go": { "branch": "master", "commit": "47694979496d4bf2e90ce75d95f1dec3f41cbefb" }, + "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, + "vim-wakatime": { "branch": "master", "commit": "98cb7a8a09f8a0cb225b5955bf491ffb9860569f" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, + "wordcounter.nvim": { "branch": "master", "commit": "5d32c00a555c35c378c9e148671963931dfbe9ed" } +} diff --git a/nvim/screenshot.png b/nvim/screenshot.png new file mode 100644 index 0000000..5f65673 Binary files /dev/null and b/nvim/screenshot.png differ diff --git a/nvim/script/fennel.bb b/nvim/script/fennel.bb new file mode 100644 index 0000000..7e4c578 --- /dev/null +++ b/nvim/script/fennel.bb @@ -0,0 +1,147 @@ +#!/usr/bin/env bb +;; vi: ft=clojure + +(ns script.fennel + (:require [clojure.string :as str] + [clojure.set :as set] + [babashka.cli :as cli] + [babashka.fs :as fs] + [babashka.process :as proc])) + +(def cli-opts + {:help {:alias :h + :desc "Prints this help"} + :compile {:alias :c + :desc "Compile all changed Fennel files into their Lua counterparts (\"changed\" means newer modified time than their Lua counterpart)"} + :dry {:alias :d + :desc "When true, it won't actually modify any files"} + :notify {:alias :n + :desc "Use notify-send to display errors alongside printing to stderr"} + :files {:alias :f + :desc "Prints the Fennel files it would operate on and exits, useful for piping into entr for \"compile on change\" support"} + :root {:alias :r + :desc "Root directory to perform all operations under" + :default "."} + :prune {:alias :p + :desc "Delete Lua files that lack a Fennel counterpart, prevents orphan Lua files from hanging around after a Fennel file deletion or rename, takes a list of globs that should not be included in the pruning (like `vendor/**.lua,my-cool.lua`)"}}) + +(defn compile-fennel-file + "Compiles the given Fennel file into a Lua file. Can return an anomaly." + [{:keys [src-path]}] + (try + (if src-path + (let [{:keys [exit out err]} + (proc/shell + {:out :string + :err :string + :continue true} + "lua" "script/fennel.lua" "--compile" src-path)] + (if (zero? exit) + out + {:cognitect.anomalies/category :cognitect.anomalies/fault + :cognitect.anomalies/message "Fennel process exited with a non-zero status code" + ::exit exit + ::err err})) + {:cognitect.anomalies/category :cognitect.anomalies/incorrect + :cognitect.anomalies/message "src-path must be a string"}) + (catch Exception e + {:cognitect.anomalies/category :cognitect.anomalies/fault + :cognitect.anomalies/message "Uncaught exception" + ::exeption-map (Throwable->map e)}))) + +(comment + (compile-fennel-file {:src-path "init.fnl"})) + +(defn display-help! [] + (let [file-name (fs/relativize (fs/cwd) *file*)] + (println (str "Usage: " file-name " [FLAG]")) + (println) + (println "Compile changed Fennel files into Lua, intended for use with Neovim configuration.") + (println) + (println "To run whenever you change a file you can combine this tool with entr https://eradman.com/entrproject/") + (println) + (println (str "Example: " file-name " --files | entr " file-name " --compile")) + (println) + (println (cli/format-opts {:spec cli-opts})))) + +(comment + (display-help!)) + +(defn notify! [summary msg] + (proc/shell "notify-send" summary msg)) + +(defn last-modified-time-ms-safe + "Will ALWAYS return a number. If there's an error it'll return a negative number." + [path] + (try + (.toMillis (fs/last-modified-time path)) + (catch Exception _e + -1))) + +(defn fnl->lua-path [fnl-path] + (str/replace (str (fs/strip-ext fnl-path) ".lua") #"^fnl/" "lua/")) + +(defn compile-changed-fennel-files! + "Find changed Fennel files that are newer than their Lua counterpart and compile them." + [{:keys [root prune dry notify] :or {root "."}}] + (let [glob #(map str (fs/glob root %)) + fnl-paths (glob "**.fnl") + lua-paths (glob "**.lua")] + + (when prune + (run! + (fn [lua-path] + (println "[delete]" lua-path) + (when (not dry) + (fs/delete lua-path))) + (set/difference + (set lua-paths) + (set (map fnl->lua-path fnl-paths)) + (set (mapcat glob prune))))) + + (run! + (fn [fnl-path] + (let [lua-path (fnl->lua-path fnl-path)] + (when (> (last-modified-time-ms-safe fnl-path) + (last-modified-time-ms-safe lua-path)) + (println "[compile]" fnl-path) + (let [lua (compile-fennel-file {:src-path fnl-path})] + (if-let [category (:cognitect.anomalies/category lua)] + (binding [*out* *err*] + (if (= :cognitect.anomalies/fault category) + (do + (println (::err lua)) + (when notify + (notify! (str fnl-path " compilation failed") (::err lua)))) + (println "[error]" lua))) + (when (not dry) + (spit lua-path (str "-- [nfnl] " fnl-path "\n" lua)))))))) + fnl-paths))) + +(defn print-fennel-file-paths! [{:keys [root] :or {root "."}}] + (run! + println + (map str (fs/glob root "**.fnl")))) + +(defn main + "Parse the input args and work out what to do." + [args] + (let [opts (update (cli/parse-opts args cli-opts) :prune + (fn [prune] + (cond + (string? prune) (str/split prune #",") + (true? prune) [] + (false? prune) nil + :else prune)))] + (cond + (:help opts) (display-help!) + (:files opts) (print-fennel-file-paths! opts) + (:compile opts) (compile-changed-fennel-files! opts) + :else (display-help!)))) + +(comment + ;; Intended to be invoked through your editor REPL during development. + (main ["--help"])) + +;; Default entrypoint of the script. +(main *command-line-args*) -- cgit v1.2.3