Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lua/**/*.lua linguist-generated
lua/nfnl/fennel.lua linguist-vendored
after/**/*.lua linguist-vendored
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/.dev/
/lua/
/plugin/packer_compiled.lua
1 change: 1 addition & 0 deletions .nfnl.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
52 changes: 52 additions & 0 deletions .projections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"*.fnl": {
"alternate": ["{}.lua"]
},
"*.lua": {
"alternate": ["{}.fnl"]
},
"fnl/magic/*.fnl": {
"type": "module",
"template": [
"; you can update or remove this template in .projections.json",
"",
"(local {open}: autoload : define{close} (require :nfnl.module))",
"",
"; example will be loaded until one of its properties of methods is used",
"(local example (autoload :some-plugin))",
"",
"(local M (define :{}))",
"",
"(fn M.my-function [arg]",
" (comment",
" (example.some-method)))",

"",
"M"
],
"alternate": [
"lua/magic/{}.lua"
]
},
"lua/magic/*.lua": {
"alternate": [
"fnl/magic/{}.fnl"
]
},
"fnl/plugins/*.fnl": {
"type": "plugin",
"template": [
"(import-macros {open}: tx{close} :magic.macros)",
"",
"(tx :plugin-url {open}:opts {open}{close}{close})"
],
"alternate": [
"lua/plugins/{}.lua"
]
},
"lua/plugins/*.lua": {
"alternate": [
"fnl/plugins/{}.fnl"
]
}
}
19 changes: 13 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
= Magic Kit

Neovim starter kit for working with https://github.com/Olical/conjure[Conjure] and https://github.com/Olical/aniseed[Aniseed], contains everything you need to get started. The goal is for you to take this and modify it to fit your needs, it is _not_ a distribution I'll constantly tweak, it's a starting point you should change as you see fit.
Neovim starter kit for working with https://github.com/Olical/conjure[Conjure] and https://github.com/Olical/nfnl[Nfnl], contains everything you need to get started. The goal is for you to take this and modify it to fit your needs, it is _not_ a distribution I'll constantly tweak, it's a starting point you should change as you see fit.

== Requirements

* git (for cloning the project and managing plugins)
* Neovim 0.7+
* Neovim 0.11+

== Installation

Expand All @@ -15,9 +15,8 @@ Neovim starter kit for working with https://github.com/Olical/conjure[Conjure] a
# Make sure you don't have anything here already! Back it up if so!
git clone git@github.com:Olical/magic-kit.git ~/.config/nvim

# Perform the initial sync which will fetch all of the plugins.
# Run then whenever you change the plugin configuration.
~/.config/nvim/script/sync.sh
# Starting neovim will perform the initial sync which will fetch all of the
# plugins.
----

Once done, have a look at `~/.config/nvim/init.lua` to learn about the bootstrap process then `~/.config/nvim/fnl/magic/init.fnl` for the real beginning of your Fennel based configuration. Good luck! Have fun!
Expand All @@ -28,10 +27,18 @@ If you press a key and then wait, https://github.com/folke/which-key.nvim[which-

* `<space>` is the https://learnvimscriptthehardway.stevelosh.com/chapters/06.html#leader[leader key] (`<leader>`)
* `,` is the https://learnvimscriptthehardway.stevelosh.com/chapters/06.html#local-leader[local leader key] (`<localleader>`)
* `<leader>f...` finds things with https://github.com/nvim-telescope/telescope.nvim[telescope]
* `<leader>f...` finds things with https://github.com/folke/snacks.nvim[snacks]
** Try `<leader>ff` to find files and `<leader>fb` to find buffers, there's a bunch of mappings so you'll have to experiment and rely on which-key
* `<leader>ut` opens https://github.com/mbbill/undotree[undotree]

== Navigation

The https://github.com/tpope/vim-fugitive[vim-fugitive] plugin is included to jump around modules, plugins, sources and generated files.

You can find or create modules and plugins using `:Emodule <name>` and `:Eplugin <name>` respectively. New files will be prepopulated with a template.

See the vim-fugitive documentation and `.projections.json` for more details.

== Unlicenced

> You can change this in your own repository, I don't care! Do what you want with this repository, attribution is appreciated but not required.
Expand Down
4 changes: 4 additions & 0 deletions after/ftplugin/fennel.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(local fennel-lua-paths (require :magic.fennel-lua-paths))

(fennel-lua-paths.setup)

3 changes: 3 additions & 0 deletions after/ftplugin/fennel.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- [nfnl] after/ftplugin/fennel.fnl
local fennel_lua_paths = require("magic.fennel-lua-paths")
return fennel_lua_paths.setup()
4 changes: 4 additions & 0 deletions after/ftplugin/lua.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(local fennel-lua-paths (require :magic.fennel-lua-paths))

(fennel-lua-paths.setup)

3 changes: 3 additions & 0 deletions after/ftplugin/lua.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- [nfnl] after/ftplugin/lua.fnl
local fennel_lua_paths = require("magic.fennel-lua-paths")
return fennel_lua_paths.setup()
19 changes: 19 additions & 0 deletions fnl/magic/fennel-lua-paths.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(local {: define} (require :nfnl.module))

(local M (define :magic.fennel-lua-paths))

(local join #(table.concat $1 ","))

(fn M.setup []
(set vim.bo.path (->> (vim.opt.rtp:get)
(vim.tbl_map #(join [$1 (.. $1 "/fnl") (.. $1 "/lua")]))
(join)))

(set vim.bo.suffixesadd (join [".fnl"
"/init.fnl"
".lua"
"/init.lua"]))

(set vim.bo.includeexpr "tr(v:fname, '.', '/')"))

M
74 changes: 6 additions & 68 deletions fnl/magic/init.fnl
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
(module magic.init
{autoload {plugin magic.plugin
nvim aniseed.nvim}})

;;; Introduction

;; Aniseed compiles this (and all other Fennel files under fnl) into the lua
;; Nfnl compiles this (and all other Fennel files under fnl) into the lua
;; directory. The init.lua file is configured to load this file when ready.

;; We'll use modules, macros and functions to define our configuration and
Expand All @@ -14,68 +10,10 @@
;; You can learn all about Conjure and how to evaluate things by executing
;; :ConjureSchool in your Neovim. This will launch an interactive tutorial.


;;; Generic configuration

(set nvim.o.termguicolors true)
(set nvim.o.mouse "a")
(set nvim.o.updatetime 500)
(set nvim.o.timeoutlen 500)
(set nvim.o.sessionoptions "blank,curdir,folds,help,tabpages,winsize")
(set nvim.o.inccommand :split)

(nvim.ex.set :spell)
(nvim.ex.set :list)


;;; Mappings

(set nvim.g.mapleader " ")
(set nvim.g.maplocalleader ",")

(require :magic.options)
(require :magic.mappings)

;;; Plugins

;; Run script/sync.sh to update, install and clean your plugins.
;; Packer configuration format: https://github.com/wbthomason/packer.nvim
(plugin.use
:Olical/aniseed {}
:Olical/conjure {}
:Olical/nvim-local-fennel {}
:PaterJason/cmp-conjure {}
:PeterRincker/vim-argumentative {}
:airblade/vim-gitgutter {}
:clojure-vim/clojure.vim {}
:clojure-vim/vim-jack-in {}
:folke/which-key.nvim {:mod :which-key}
:ggandor/lightspeed.nvim {}
:guns/vim-sexp {:mod :sexp}
:hrsh7th/cmp-buffer {}
:hrsh7th/cmp-cmdline {}
:hrsh7th/cmp-nvim-lsp {}
:hrsh7th/cmp-path {}
:hrsh7th/nvim-cmp {:mod :cmp}
:jiangmiao/auto-pairs {:mod :auto-pairs}
:lewis6991/impatient.nvim {}
:liuchengxu/vim-better-default {:mod :better-default}
:marko-cerovac/material.nvim {:mod :material}
:mbbill/undotree {:mod :undotree}
:neovim/nvim-lspconfig {:mod :lspconfig}
:nvim-lualine/lualine.nvim {:mod :lualine}
:nvim-telescope/telescope.nvim {:mod :telescope :requires [[:nvim-lua/popup.nvim] [:nvim-lua/plenary.nvim]]}
:nvim-treesitter/nvim-treesitter {:mod :treesitter}
:radenling/vim-dispatch-neovim {}
:tpope/vim-abolish {}
:tpope/vim-commentary {}
:tpope/vim-dispatch {}
:tpope/vim-eunuch {}
:tpope/vim-fugitive {}
:tpope/vim-repeat {}
:tpope/vim-sexp-mappings-for-regular-people {}
:tpope/vim-sleuth {}
:tpope/vim-surround {}
:tpope/vim-unimpaired {}
:tpope/vim-vinegar {}
:w0rp/ale {:mod :ale}
:wbthomason/packer.nvim {}
)
(local lazy (require :lazy))
;; Any file under the `fnl/plugins/` directory will be loaded as a plugin.
(lazy.setup :plugins {})
40 changes: 31 additions & 9 deletions fnl/magic/macros.fnl
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
;; Trick vim-sleuth into using the right indentation for this file.
(do
true)
;; [nfnl-macro]

;; These macro functions are executed at compile time to transform our code,
;; add more expressive syntax and create domain specific languages.
Expand All @@ -9,8 +7,7 @@
;; compiler.

;; Example:
; (module my.fennel.module
; {require-macros [magic.macros]})
; (import-macros {: some-macro} :magic.macros)
; (some-macro 123)

;; I consider this to be an advanced concept within Lisp languages but one you
Expand All @@ -26,17 +23,42 @@

{;; This is just a silly example macro.
; (infix-example-macro 2 + 3) => compiles to: (+ 2 3) => evaluates to: 5
:infix-example-macro
(fn [x op y]
(fn infix-example-macro [x op y]
`(,op ,x ,y))

;; Create an augroup for your autocmds.
; (augroup my-group
; (nvim.ex.autocmd ...))
:augroup
(fn [name ...]
(fn augroup [name ...]
`(do
(vim.cmd (.. "augroup " ,(tostring name) "\nautocmd!"))
,...
(vim.cmd "augroup END")
nil))}

(fn tx [...]
"
Merge sequential and key-value tables.

For example, in Lua, we can write:

{'some-string', a = 1, b = 2}

And automatically store the string with a numeric key.

Fennel can't mix both, so to generate the table above,
we would call it as:

(tx :some-string {:a 1 :b 2})
"
(local input [...])
(local last-index (length input))
(local props (. input last-index))
(each [i v (ipairs input)]
(if (~= i last-index)
(tset props i v)))
`(-> ,props))

{: infix-example-macro
: augroup
: tx}
60 changes: 60 additions & 0 deletions fnl/magic/mappings.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
;;; Mappings

(local {: autoload} (require :nfnl.module))
(local {: lmap : nmap} (require :magic.util))
(local snacks (autoload :snacks))

(set vim.g.mapleader " ")
(set vim.g.maplocalleader ",")

;; finders
(lmap :f :<ignore> {:desc :find})
(lmap :ff #(snacks.picker.files) {:desc "files"})
(lmap :f- #(snacks.explorer.reveal) {:desc "current file"})
(lmap :fg #(snacks.picker.grep) {:desc "live grep"})
(lmap :* #(snacks.picker.grep_word) {:desc "grep word"})
(lmap :fb #(snacks.picker.buffers) {:desc "buffers"})
(lmap :fh #(snacks.picker.help) {:desc "help"})
(lmap :fm #(snacks.picker.keymaps) {:desc "keymaps"})
(lmap :fM #(snacks.picker.marks) {:desc "marks"})
(lmap :fo #(snacks.picker.recent) {:desc "old files"})
(lmap :fc #(snacks.picker.commands) {:desc "commands"})
(lmap :fC #(snacks.picker.command_history) {:desc "command history"})
(lmap :fq #(snacks.picker.qflist) {:desc "quickfix"})
(lmap :fl #(snacks.picker.loclist) {:desc "loclist"})
(lmap :fs #(snacks.picker) {:desc "snacks pickers"})

;; lsp
(lmap :l :<ignore> {:desc :lsp})
(lmap :la #(snacks.picker.lsp_code_actions) {:desc "code actions"})
(lmap :li #(snacks.picker.lsp_implementations) {:desc "implementations"})
(lmap :lf #(snacks.picker.lsp_references) {:desc "find references"})
(lmap :lt #(snacks.picker.lsp_type_definitions) {:desc "type definitions"})
(lmap :ls #(snacks.picker.lsp_document_symbols) {:desc "document symbols"})
(lmap :lS #(snacks.picker.lsp_workspace_symbols) {:desc "workspace symbols"})
(lmap :lr #(vim.lsp.buf.rename) {:desc "rename"})
(lmap :lf #(vim.lsp.buf.format {:async true}) {:desc "format"})
(lmap :lh #(vim.lsp.buf.hover) {:desc "hover"})
(lmap :ld #(vim.lsp.buf.definition) {:desc "definition"})
(lmap :lD #(vim.lsp.buf.declaration) {:desc "declaration"})

;; diagnostics
(lmap :d :<ignore> {:desc :diagnostics})
(lmap :dn #(vim.diagnostic.jump {:count 1 :float true}) {:desc "next"})
(lmap :dp #(vim.diagnostic.jump {:count -1 :float true}) {:desc "previous"})

;; notifications
(lmap :n :<ignore> {:desc :notifications})
(lmap :no #(snacks.picker.notifications) {:desc "open"})
(lmap :nd #(snacks.notifier.hide) {:desc "dismiss"})

;; git
(lmap :g :<ignore> {:desc :git})
(lmap :gg :<cmd>Git<cr> {:desc "status"})
(lmap :gb "<cmd>Git blame<cr>" {:desc "blame"})
(lmap :gw "<cmd>Gwrite<cr>" {:desc "write"})
(lmap :gr "<cmd>Gread<cr>" {:desc "read"})

;; special cases
(nmap :<localleader>l :<cmd>Lazy<cr> {:desc :Lazy})
(nmap :<localleader>c #(snacks.picker.files {:dirs [(vim.fs.dirname vim.env.MYVIMRC)]}) {:desc "Neovim config"})
21 changes: 21 additions & 0 deletions fnl/magic/options.fnl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;;; General options

(set vim.o.termguicolors true)
(set vim.o.mouse "a")
(set vim.o.updatetime 500)
(set vim.o.timeoutlen 500)
(set vim.o.sessionoptions "blank,curdir,folds,help,tabpages,winsize")
(set vim.o.inccommand :split)
(set vim.o.spell false)
(set vim.o.list true)

;;; Better defaults
(set vim.o.number false)
(set vim.o.relativenumber false)
(set vim.o.wrap true)
(set vim.o.cursorline false)
(set vim.o.wildmode :full)
(set vim.o.wildoptions :pum)

(comment
(vim.o.clipboard :unnamedplus))
Loading