feat: add fennel and test fennel configuration

This commit is contained in:
Youwen Wu 2025-02-01 02:29:18 -08:00
parent 14ba7c5dd3
commit 8ff882a903
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
8 changed files with 101 additions and 21 deletions

32
.nfnl.fnl Normal file
View file

@ -0,0 +1,32 @@
{;; Enables verbose notifications from nfnl, including notifications about
;; when it starts up and when it compiles successfully. Useful for debugging
;; the plugin itself and checking that it's running when you expect it to.
:verbose true
;; Passed to fennel.compileString when your code is compiled.
;; See https://fennel-lang.org/api for more information.
:compiler-options {;; Disables ansi escape sequences in compiler output.
:error-pinpoint false
:compilerEnv _G}
;; Warning! In reality these paths are absolute and set to the root directory
;; of your project (where your .nfnl.fnl file is). This means even if you
;; open a .fnl file from outside your project's cwd the compiler will still
;; find your macro files. If you use relative paths like I'm demonstrating here
;; then macros will only work if your cwd is in the project you're working on.
;; They also use OS specific path separators, what you see below is just an example really.
;; I'm not including nfnl's directory from your runtimepath, but it would be there by default.
;; See :rtp-patterns below for more information on including other plugins in your path.
;; String to set the compiler's fennel.path to before compilation.
:fennel-path "./?.fnl;./?/init.fnl;./fnl/?.fnl;./fnl/?/init.fnl"
;; String to set the compiler's fennel.macro-path to before compilation.
:fennel-macro-path "./?.fnl;./?/init-macros.fnl;./?/init.fnl;./fnl/?.fnl;./fnl/?/init-macros.fnl;./fnl/?/init.fnl"
;; A list of glob patterns (autocmd pattern syntax) of files that
;; should be compiled. This is used as configuration for the BufWritePost
;; autocmd, so it'll only apply to buffers you're interested in.
;; Will use backslashes on Windows.
;; Defaults to compiling all .fnl files, you may want to limit it to your fnl/ directory.
:source-file-patterns [:./fnl/.*.fnl :./fnl/*.fnl :./fnl/**/*.fnl :init.fnl]
;; A function that is given the absolute path of a Fennel file and should return
;; the equivalent Lua path, by default this will translate `fnl/foo/bar.fnl` to `lua/foo/bar.lua`.
;; See the "Writing Lua elsewhere" tip below for an example function that writes to a sub directory.
;:fnl-path->lua-path (fn [fnl-path] ...)
}

View file

@ -106,6 +106,7 @@
p: p:
(with p; [ (with p; [
lua lua
fennel
c c
javascript javascript
typescript typescript
@ -306,6 +307,7 @@
stylua stylua
fennel-ls fennel-ls
fennel fennel
fnlfmt
] ]
); );
}; };

1
flsproject.fnl Normal file
View file

@ -0,0 +1 @@
{:extra-globals :vim}

14
fnl/config/macros.fnl Normal file
View file

@ -0,0 +1,14 @@
;; [nfnl-macro]
(fn tx [& args]
"Mixed sequential and associative tables at compile time. Because the Neovim ecosystem loves them but Fennel has no neat way to express them (which I think is fine, I don't like the idea of them in general)."
(let [to-merge (when (table? (. args (length args)))
(table.remove args))]
(if to-merge
(do
(each [key value (pairs to-merge)]
(tset args key value))
args)
args)))
{: tx}

41
fnl/keymaps.fnl Normal file
View file

@ -0,0 +1,41 @@
;; Mostly remaps of existing keys. New keybinds are generally defined directly
;; in their plugin specs for `lz.n`
(set vim.g.mapleader " ")
(vim.keymap.set :n :<leader> :<nop>)
(vim.keymap.set :t :<C-Esc> "<C-\\><C-n>")
(vim.keymap.set :n :<C-d> :<C-d>zz)
(vim.keymap.set :n :<C-u> :<C-u>zz)
;; when searching, also center screen and reopen folds
(vim.keymap.set :n :n :nzzzv)
(vim.keymap.set :n :N :Nzzzv)
;; The greatest remap of all time -- the primeagen
(vim.keymap.set [:n :v] :<leader>D "\"_D"
{:desc "same as D but send to black hole register"})
(vim.keymap.set [:n :v] :<leader>d "\"_d"
{:desc "same as `d` but send to black hole register"})
;; The real greatest remap(s) of all time -- me
(vim.keymap.set [:n :v] :<leader>y "\"+y" {:desc "yank to clipboard"})
(vim.keymap.set [:n :v] :<leader>Y "\"+Y"
{:desc "yank rest of line to clipboard"})
(vim.keymap.set [:n :v] :<leader>p "\"+p"
{:desc "put after cursor from clipboard"})
(vim.keymap.set [:n :v] :<leader>P "\"+P"
{:desc "put before cursor from clipboard"})
;; lsp
(vim.keymap.set :n :<leader>cr vim.lsp.buf.rename)
;; misc
(vim.keymap.set :v :<C-a> :<C-a>gv)
(vim.keymap.set :v :<C-x> :<C-x>gv)
(vim.keymap.set :v :g<C-a> :g<C-a>gv)
(vim.keymap.set :v :g<C-x> :g<C-x>gv)
(vim.keymap.set :i :<Tab> (. (require :scripts.intellitab) :indent))
{}

View file

@ -1,33 +1,21 @@
-- Mostly remaps of existing keys. New keybinds are generally defined directly -- [nfnl] Compiled from ./fnl/keymaps.fnl by https://github.com/Olical/nfnl, do not edit.
-- in their plugin specs for `lz.n`
vim.g.mapleader = " " vim.g.mapleader = " "
vim.keymap.set("n", "<leader>", "<nop>") vim.keymap.set("n", "<leader>", "<nop>")
vim.keymap.set("t", "<C-Esc>", "<C-\\><C-n>") vim.keymap.set("t", "<C-Esc>", "<C-\\><C-n>")
vim.keymap.set("n", "<C-d>", "<C-d>zz") vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz") vim.keymap.set("n", "<C-u>", "<C-u>zz")
-- when searching, also center screen and reopen folds
vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv") vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set({"n", "v"}, "<leader>D", "\"_D", {desc = "same as D but send to black hole register"})
-- The greatest remap of all time -- the primeagen vim.keymap.set({"n", "v"}, "<leader>d", "\"_d", {desc = "same as `d` but send to black hole register"})
vim.keymap.set({ "n", "v" }, "<leader>d", '"_d', { desc = "same as `d` but send to black hole register" }) vim.keymap.set({"n", "v"}, "<leader>y", "\"+y", {desc = "yank to clipboard"})
vim.keymap.set({ "n", "v" }, "<leader>D", '"_D', { desc = "same as `D` but send to black hole register" }) vim.keymap.set({"n", "v"}, "<leader>Y", "\"+Y", {desc = "yank rest of line to clipboard"})
-- The real greatest remap(s) of all time -- me vim.keymap.set({"n", "v"}, "<leader>p", "\"+p", {desc = "put after cursor from clipboard"})
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "yank to clipboard" }) vim.keymap.set({"n", "v"}, "<leader>P", "\"+P", {desc = "put before cursor from clipboard"})
vim.keymap.set({ "n", "v" }, "<leader>Y", '"+Y', { desc = "yank rest of line to clipboard" }) vim.keymap.set("n", "<leader>cr", vim.lsp.buf.rename)
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p', { desc = "put after cursor from clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>P", '"+P', { desc = "put before cursor from clipboard" })
-- Allow increment/decrement repeatedly in visual
vim.keymap.set("v", "<C-a>", "<C-a>gv") vim.keymap.set("v", "<C-a>", "<C-a>gv")
vim.keymap.set("v", "<C-x>", "<C-x>gv") vim.keymap.set("v", "<C-x>", "<C-x>gv")
vim.keymap.set("v", "g<C-a>", "g<C-a>gv") vim.keymap.set("v", "g<C-a>", "g<C-a>gv")
vim.keymap.set("v", "g<C-x>", "g<C-x>gv") vim.keymap.set("v", "g<C-x>", "g<C-x>gv")
vim.keymap.set("n", "<leader>cr", vim.lsp.buf.rename)
vim.keymap.set("i", "<Tab>", require("scripts.intellitab").indent) vim.keymap.set("i", "<Tab>", require("scripts.intellitab").indent)
return {}

View file

@ -67,6 +67,7 @@ return {
tex = { "latexindent" }, tex = { "latexindent" },
cpp = { "clang-format", lsp_format = "fallback" }, cpp = { "clang-format", lsp_format = "fallback" },
c = { "clang-format", lsp_format = "fallback" }, c = { "clang-format", lsp_format = "fallback" },
fennel = { "fnlfmt", lsp_format = "fallback" },
}, },
}) })

View file

@ -304,4 +304,5 @@ return {
end) end)
end, end,
}, },
{ "nfnl", ft = { "fennel" } },
} }