nvim - move from aniseed to nfnl

This commit is contained in:
2025-05-14 16:00:47 -05:00
parent d08ce2685e
commit 240abfc7f6
48 changed files with 766 additions and 64 deletions

View File

@@ -1 +1 @@
{:source-file-patterns [:fnl/**/*.fnl]}
{}

View File

@@ -1,4 +1,4 @@
(local a (require :aniseed.core))
(local a (require :nfnl.core))
(local u (require :dotfiles.util))
(vim.cmd.set :shortmess+=c)
@@ -117,8 +117,3 @@
(vim.api.nvim_create_user_command :FennelScratchBuffer make-fennel-scratch {})
(u.nnoremap :<leader>fsb ":call FennelScratchBuffer ()<CR>")
;; (fn compile-fnl [] (print :recompiling)
;; (anenv.init {:force true :init :dotfiles.init}))
;;
;; (vim.api.nvim_create_user_command :AniseedCompile compile-fnl {})

View File

@@ -1,5 +1,17 @@
(local a (require :aniseed.core))
(local a (require :nfnl.core))
(local str (require :nfnl.string))
(local fs (require :nfnl.fs))
(fn require-all []
(let [require-exclusions (a.->set [:init])]
(->> (fs.relglob :fnl/dotfiles :*.fnl)
(a.map #(a.first (str.split $ :.fnl)))
(a.filter #(not (a.contains? require-exclusions $)))
(a.map #(.. :dotfiles. $))
;(a.map #(require $))
)))
;; (require-all)
(require :dotfiles.core)
(require :dotfiles.plugins)
(require :dotfiles.mapping)

View File

@@ -1,4 +1,6 @@
(local util (require :dotfiles.util))
(local nfnl (require :nfnl.api))
(fn noremap [mode from to]
"Sets a mapping with {:noremap true}."
@@ -6,17 +8,12 @@
; (set nvim.g.mapleader "\\")
(fn aniseed-reload []
(each [k _ (ipairs package.loaded)]
(when (string.match k "^dotfiles%..+")
(tset package.loaded k nil)))
((. (require :aniseed.env) :init) {:module :dotfiles.init :compile true})
(print "aniseed reloaded!"))
(vim.keymap.set :n "<leader>`" aniseed-reload)
(vim.keymap.set :n "<leader>`"
(fn []
(nfnl.compile-all-files (vim.fn.stdpath :config))
(vim.cmd.source (.. (vim.fn.stdpath :config) :/init.lua))))
; (noremap :n "<leader>`" ":source ~/.config/nvim/init.lua<CR>")
(noremap :n :<leader>! ":call AniseedCompile()<CR>")
(noremap :n :<Enter> ":nohlsearch<Enter>/<BS>")

View File

@@ -1,4 +1,5 @@
(local core (require :aniseed.core))
(local core (require :nfnl.core))
(local conjure-config (require :conjure.config))
; (set nvim.g.conjure#eval#result_register "*")
; (set nvim.g.conjure#log#botright true)
@@ -6,7 +7,7 @@
(set vim.g.conjure#client#clojure#nrepl#mapping#session_clone :sC)
(set vim.g.conjure#extract#tree_sitter#enabled true)
(let [conjure-config (require :conjure.config)]
(conjure-config.assoc-in [:filetypes]
(core.concat (conjure-config.filetypes) [:markdown]))
(conjure-config.assoc-in [:filetype :markdown] :conjure.client.clojure.nrepl))
(conjure-config.assoc-in [:filetypes]
(core.concat (conjure-config.filetypes) [:markdown]))
(conjure-config.assoc-in [:filetype :markdown] :conjure.client.clojure.nrepl)

View File

@@ -5,9 +5,9 @@
(fn bufmap [mode from to] (util.noremap mode from to {:local? true}))
(fn map-fugitive-keys []
(bufmap :n :<leader>gp ":Git pull<CR>" )
(bufmap :n :<leader>gp ":Git pull<CR>")
(bufmap :n :<leader>gP ":Git push<CR>")
(bufmap :n :<leader>gF ":Git push -f<CR>"))
(vim.api.nvim_create_autocmd [:FileType]
{:pattern :fugitive :callback map-fugitive-keys})
{:pattern :fugitive :callback map-fugitive-keys})

View File

@@ -1,4 +1,4 @@
(local a (require :aniseed.core))
(local a (require :nfnl.core))
(local u (require :dotfiles.util))
(local lsp (require :vim.lsp))
(local lspconfig (require :lspconfig))
@@ -122,9 +122,8 @@
(fn default-server-handler [server-name]
(let [specific-opts (a.get server-specific-opts server-name {})
server (a.get lspconfig server-name)
server-opts (a.merge base-server-opts specific-opts)]
(server.setup server-opts)))
(vim.lsp.config server-name server-opts)))
(fn lsp-execute-command [cmd ...]
(let [buf-uri (vim.uri_from_bufnr 0)
@@ -135,7 +134,6 @@
args (a.concat opts [...])]
(vim.lsp.buf.execute_command {:command cmd :arguments args})))
(fn setup-handlers [language_servers]
(each [_ server-name (pairs language_servers)]
(default-server-handler server-name)))
@@ -149,8 +147,4 @@
; (mason-lspconfig.setup)
; (mason-lspconfig.setup_handlers [default-server-handler])))
{: on_attach
: default-server-handler
: setup-handlers
}
{: on_attach : default-server-handler : setup-handlers}

View File

@@ -1,14 +1,12 @@
(local mason (require :mason))
(local mason-lspconf (require :mason-lspconfig) )
(local mason-lspconf (require :mason-lspconfig))
(local lspconfig (require :dotfiles.plugin.lspconfig))
(local a (require :aniseed.core))
(fn setup []
(mason.setup {:ui {:icons {:package_installed "✓"}}})
(when mason-lspconf
(mason-lspconf.setup {:ensure_installed [:lua_ls]})
(lspconfig.setup-handlers (mason-lspconf.get_installed_servers))))
(mason.setup {:ui {:icons {:package_installed "✓"}}})
(when mason-lspconf
(mason-lspconf.setup {:ensure_installed [:lua_ls] :automatic_enable true})
(lspconfig.setup-handlers (mason-lspconf.get_installed_servers))))
(setup)
;; (mason.setup)

View File

@@ -0,0 +1,2 @@
(local nfnl (require :nfnl))
(nfnl.setup {:compile_on_write true})

View File

@@ -1,4 +1,4 @@
(local core (require :aniseed.core))
(local core (require :nfnl.core))
(local conceal (require :dotfiles.conceal))
(local ts-utils (require :dotfiles.ts-utils))
(local stars ["◉" "⦾" "○" "✸" "✿" "✶" "•" "‣"])

View File

@@ -1,4 +1,4 @@
(local a (require :aniseed.core))
(local a (require :nfnl.core))
(local treesitter (require :dotfiles.plugin.treesitter))
(local ts-parsers (require :nvim-treesitter.parsers))
(local ts-utils (require :nvim-treesitter.ts_utils))
@@ -53,19 +53,25 @@
(fn TreeSitterLangParedit []
(when (host-lang-in? paredit-host-langs)
(when-let [cursor-lang (language-at-cursor)]
(->> cursor-lang
(paredit-lang?)
(bool->int)
(set vim.g.paredit_mode))
(vim.fn.PareditInitBuffer))))
(let [cursor-lang (language-at-cursor)]
(when cursor-lang
(->> cursor-lang
(paredit-lang?)
(bool->int)
(set vim.g.paredit_mode))
(vim.fn.PareditInitBuffer)))))
(vim.api.nvim_create_autocmd [:FileType]
{:pattern :ruby :callback (lambda [] (vim.fn.PareditInitBalancingAllBracketsBuffer))})
{:pattern :ruby
:callback (lambda []
(vim.fn.PareditInitBalancingAllBracketsBuffer))})
(vim.api.nvim_create_autocmd [:FileType]
{:pattern :javascript :callback (lambda [] (vim.fn.PareditInitBalancingAllBracketsBuffer))})
{:pattern :javascript
:callback (lambda []
(vim.fn.PareditInitBalancingAllBracketsBuffer))})
(vim.api.nvim_create_autocmd [:FileType]
{:pattern terraform :callback (lambda [] ( vim.fn.PareditInitBalancingAllBracketsBuffer))})
{:pattern :terraform
:callback (lambda []
(vim.fn.PareditInitBalancingAllBracketsBuffer))})

View File

@@ -1,5 +1,5 @@
(local packer (require :packer))
(local core (require :aniseed.core))
(local core (require :nfnl.core))
(fn safe-require-plugin-config [name]
(let [(ok? val-or-err) (pcall require (.. :dotfiles.plugin. name))]
@@ -15,7 +15,7 @@
(-?> (. opts :mod) (safe-require-plugin-config))
(use (core.assoc opts 1 name))))))
(local packages {:Olical/aniseed {}
(local packages {:Olical/nfnl {}
:Olical/conjure {:mod :conjure}
:Olical/fennel.vim {}
:ahmedkhalf/project.nvim {}
@@ -48,7 +48,7 @@
:requires [:nvim-lua/plenary.nvim]}
:junegunn/vim-easy-align {:mod :easyalign}
:kovisoft/paredit {:mod :paredit
:require [:nvim-treesitter/nvim-treesitter] }
:require [:nvim-treesitter/nvim-treesitter]}
:kristijanhusak/vim-dadbod-completion {}
:kristijanhusak/vim-dadbod-ui {}
:L3MON4D3/LuaSnip {:mod :luasnip}
@@ -57,12 +57,21 @@
; :michaelb/sniprun {:run "bash ./install.sh" :mod :sniprun}
:mrjones2014/smart-splits.nvim {:mod :smartsplits}
:mechatroner/rainbow_csv {}
:MunifTanjim/nui.nvim {}
:neovim/nvim-lspconfig {:mod :lspconfig}
:norcalli/nvim-colorizer.lua {:mod :colorizer}
:nvim-neo-tree/neo-tree.nvim {:branch :v3.x
:require [:nvim-lua/plenary.nvim
:nvim-tree/nvim-web-devicons
; not strictly required, but recommended
:MunifTanjim/nui.nvim
; :3rd/image.nvim, ; Optional image support in preview window: See `# Preview Mode` for more information
]}
:nvim-orgmode/orgmode {:mod :orgmode}
:nvim-telescope/telescope.nvim {:requires [[:nvim-lua/popup.nvim]
[:nvim-lua/plenary.nvim]]
:mod :telescope}
:nvim-tree/nvim-web-devicons {}
:nvim-treesitter/nvim-treesitter {:run ":TSUpdate"
:mod :treesitter}
:nvim-treesitter/playground {}

View File

@@ -1,4 +1,4 @@
(local core (require :aniseed.core))
(local core (require :nfnl.core))
(fn root [bufnr lang]
(let [parser (vim.treesitter.get_parser bufnr lang {})

View File

@@ -1,4 +1,4 @@
(local a (require :aniseed.core))
(local a (require :nfnl.core))
(fn noremap [mode from to opts]
(let [map-opts {:noremap true :silent true}

View File

@@ -4,7 +4,7 @@ local fn = vim.fn
local pack_path = fn.stdpath("data") .. "/site/pack"
local fmt = string.format
function ensure (user, repo)
function ensure(user, repo)
-- Ensures a given github.com/USER/REPO is cloned in the pack/packer/start directory.
local install_path = fmt("%s/packer/start/%s", pack_path, repo, repo)
if fn.empty(fn.glob(install_path)) > 0 then
@@ -15,11 +15,13 @@ end
-- Bootstrap essential plugins required for installing and loading the rest.
ensure("wbthomason", "packer.nvim")
ensure("Olical", "aniseed")
-- ensure("Olical", "aniseed")
ensure("lifepillar", "vim-solarized8")
-- Enable Aniseed's automatic compilation and loading of Fennel source code.
vim.g["aniseed#env"] = {
module = "dotfiles.init",
compile = true
}
-- vim.g["aniseed#env"] = {
-- module = "dotfiles.init",
-- compile = true
-- }
--
require 'dotfiles.init'

View File

@@ -0,0 +1,30 @@
-- [nfnl] fnl/dotfiles/conceal.fnl
local u = require("dotfiles.util")
local conceals = {defn = "\240\157\145\147", fn = "\206\187", lambda = "\206\187", ["and"] = "\226\136\167", ["&&"] = "\226\136\167", ["or"] = "\226\136\168", ["||"] = "\226\136\168", ["not"] = "\194\172", ["!"] = "\194\172", ["for"] = "\226\136\128", ["in"] = "\226\136\136", ["true"] = "\226\138\164", ["false"] = "\226\138\165"}
local function setup_conceals()
vim.fn.clearmatches()
for the_match, replacement in pairs(conceals) do
local the_match0 = ("\\<" .. the_match .. "\\>")
vim.fn.matchadd("Conceal", the_match0, 0, -1, {conceal = replacement})
end
vim.wo.conceallevel = 2
vim.wo.concealcursor = "nvc"
return nil
end
local function toggle_conceal()
if (0 == vim.wo.conceallevel) then
vim.wo.conceallevel = 2
return nil
else
vim.wo.conceallevel = 0
return nil
end
end
vim.api.nvim_create_user_command("ToggleConceal", toggle_conceal, {})
vim.api.nvim_create_user_command("SetupConceals", setup_conceals, {})
u.nnoremap("<leader>ts", "call ToggleConceal()")
local pretty_filetypes = {"fennel", "clojure"}
for _, ftype in pairs(pretty_filetypes) do
vim.api.nvim_create_autocmd({"FileType"}, {pattern = ftype, callback = setup_conceals})
end
return {["setup-conceals"] = setup_conceals}

View File

@@ -0,0 +1,46 @@
-- [nfnl] fnl/dotfiles/core.fnl
local a = require("nfnl.core")
local u = require("dotfiles.util")
vim.cmd.set("shortmess+=c")
vim.cmd.set("path+=**")
vim.cmd.set("wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*")
local function safe_source(filename)
local glob = vim.fn.glob(filename)
if not a["empty?"](glob) then
return vim.fn.source(filename)
else
return nil
end
end
local backup_dir = (vim.fn.glob("$HOME") .. "/.vim/backup")
local undo_dir = (vim.fn.glob("$HOME") .. "/.vim/backup")
local on_opts = {"autoindent", "autoread", "expandtab", "exrc", "hlsearch", "ignorecase", "incsearch", "number", "ruler", "secure", "shiftround", "showcmd", "showmatch", "smartcase", "splitbelow", "splitright", "termguicolors", "title", "undofile", "wildmenu"}
local val_based_opts = {laststatus = 2, encoding = "utf-8", history = 500, redrawtime = 5000, scrolloff = 3, guifont = "Hasklig", guifontwide = "Hasklig", background = "dark", backupdir = backup_dir, directory = backup_dir, grepprg = "ag --vimgrep", tags = "tags", updatetime = 300, signcolumn = "auto:1-3", colorcolumn = {81, 100}, cmdheight = 2, undodir = undo_dir, undolevels = 1000, undoreload = 10000, foldmethod = "expr", foldexpr = "nvim_treesitter#foldexpr()", foldlevelstart = 100, foldlevel = 99, tabstop = 2, shiftwidth = 2, softtabstop = 2, mouse = "", list = true, listchars = "tab:\226\158\165\\ ,trail:\194\183,nbsp:\226\150\160", backspace = "indent,eol,start", wildmode = "list:longest,list:full", wrap = false}
local append_val_opts = {diffopt = "algorithm:patience"}
local function set_opt(_2_)
local opt = _2_[1]
local val = _2_[2]
vim.opt[a.str(opt)] = val
return nil
end
local function set_opt_2b(_3_)
local opt = _3_[1]
local val = _3_[2]
local existing_opt_val = a.get(vim.o, opt)
vim.opt[a.str(opt)] = a.str(existing_opt_val, ",", val)
return nil
end
local function set_opt_on(opt)
return set_opt({opt, true})
end
a.map(set_opt_on, on_opts)
a["map-indexed"](set_opt, val_based_opts)
a["map-indexed"](set_opt_2b, append_val_opts)
vim.cmd.syntax("on")
vim.cmd.colorscheme("solarized8")
vim.api.nvim_create_autocmd({"vimenter"}, {pattern = "*", command = "colorscheme solarized8", nested = true})
local function make_fennel_scratch()
return vim.cmd("new | setlocal bt=nofile bh=wipe nobl noswapfile nu filetype=fennel")
end
vim.api.nvim_create_user_command("FennelScratchBuffer", make_fennel_scratch, {})
return u.nnoremap("<leader>fsb", ":call FennelScratchBuffer ()<CR>")

View File

@@ -0,0 +1,23 @@
-- [nfnl] fnl/dotfiles/init.fnl
local a = require("nfnl.core")
local str = require("nfnl.string")
local fs = require("nfnl.fs")
local function require_all()
local require_exclusions = a["->set"]({"init"})
local function _1_(_241)
return ("dotfiles." .. _241)
end
local function _2_(_241)
return not a["contains?"](require_exclusions, _241)
end
local function _3_(_241)
return a.first(str.split(_241, ".fnl"))
end
return a.map(_1_, a.filter(_2_, a.map(_3_, fs.relglob("fnl/dotfiles", "*.fnl"))))
end
require("dotfiles.core")
require("dotfiles.plugins")
require("dotfiles.mapping")
require("dotfiles.conceal")
require("dotfiles.zoom-toggle")
return a.println("(re)loaded")

View File

@@ -0,0 +1,38 @@
-- [nfnl] fnl/dotfiles/mapping.fnl
local util = require("dotfiles.util")
local nfnl = require("nfnl.api")
local function noremap(mode, from, to)
return vim.keymap.set(mode, from, to, {noremap = true})
end
local function _1_()
nfnl["compile-all-files"](vim.fn.stdpath("config"))
return vim.cmd.source((vim.fn.stdpath("config") .. "/init.lua"))
end
vim.keymap.set("n", "<leader>`", _1_)
noremap("n", "<Enter>", ":nohlsearch<Enter>/<BS>")
noremap("n", "<leader>zz", ":normal! 1z=<cr>")
noremap("i", "<C-V><C-O>", ":set paste<CR><C-R><C-R>+<C-O>:set nopaste<CR>")
noremap("n", "<F5>", "\"=strftime(\"%F\")<CR>p")
noremap("i", "<F5>", "<C-R>=strftime(\"%F\")<CR>")
noremap("n", "<M-5>", "\"=trim(system('date -u'))<CR>p")
noremap("i", "<M-5>", "<C-R>=trim(system('date -u'))<CR>")
noremap("v", "<leader>ah", "S<a href=\"\" target=\"_blank\" rel=\"nopener noreferrer\"><CR>")
noremap("v", "<leader>ml", "xi[<c-r>\"]()<esc>")
noremap("n", "<C-e>", "3<C-e>")
noremap("n", "<C-y>", "3<C-y>")
noremap("n", "<C-k>", "[e")
noremap("n", "<C-j>", "]e")
noremap("v", "<C-k>", "[egv")
noremap("v", "<C-j>", "]egv")
noremap("n", "<leader>jpp", ":%!python -m json.tool --indent=2<CR>")
noremap("c", "w!!", "w !sudo tee % >/dev/null")
noremap("n", "gnh", ":GitGutterNextHunk<CR>")
noremap("n", "gph", ":GitGutterPrevHunk<CR>")
noremap("n", "gsh", ":GitGutterStageHunk<CR>")
noremap("n", "<leader>mv", ":AsyncRun -mode=bang open -a Marked\\ 2.app '%:p'<cr>")
vim.api.nvim_create_autocmd({"FileType"}, {pattern = "sql", command = "nmap <leader>s vap<leader>S"})
noremap("n", "Q", ":.!bash <CR>")
util.lvnoremap("tw", "<C-U>s/\\s\\+$//ge<CR>:nohlsearch<Enter>/<BS>")
util.lnnoremap("tw", "<C-U>.s/\\s\\+$//ge<CR>:nohlsearch<Enter>/<BS>")
util.lnnoremap("<C-k>", ":set scrollback=1 | :set scrollback 100000<cr>", {silent = true})
return util.ltnoremap("<C-k>", "<C-\\><C-n><leader><C-l>i", {silent = true})

View File

@@ -0,0 +1,18 @@
-- [nfnl] fnl/dotfiles/plugin/cmp.fnl
local cmp = require("cmp")
local luasnip = require("luasnip")
local cmp_src_menu_items = {buffer = "buff", conjure = "conj", nvim_lsp = "lsp"}
local cmp_srcs = {{name = "nvim_lsp"}, {name = "nvim_lua"}, {name = "luasnip"}, {name = "vsnip"}, {name = "conjure"}, {name = "buffer"}, {name = "orgmode"}, {name = "emoji", max_item_count = 8}}
local cmp0 = require("cmp")
local function _1_(entry, item)
item.menu = (cmp_src_menu_items[entry.source.name] or "")
return item
end
local function _2_(args)
if args then
return luasnip.lsp_expand(args.body)
else
return nil
end
end
return cmp0.setup({formatting = {format = _1_}, mapping = {["<C-p>"] = cmp0.mapping.select_prev_item(), ["<C-n>"] = cmp0.mapping.select_next_item(), ["<C-b>"] = cmp0.mapping.scroll_docs(( - 4)), ["<C-f>"] = cmp0.mapping.scroll_docs(4), ["<C-Space>"] = cmp0.mapping.complete(), ["<C-e>"] = cmp0.mapping.close(), ["<C-y>"] = cmp0.mapping.confirm({select = true})}, snippet = {expand = _2_}, sources = cmp_srcs})

View File

@@ -0,0 +1,3 @@
-- [nfnl] fnl/dotfiles/plugin/colorizer.fnl
local colorizer = require("colorizer")
return colorizer.setup({"*"}, {RGB = true, RRGGBB = true, names = true, RRGGBBAA = true, rgb_fn = true, hsl_fn = true, css = true, css_fn = true})

View File

@@ -0,0 +1,8 @@
-- [nfnl] fnl/dotfiles/plugin/conjure.fnl
local core = require("nfnl.core")
local conjure_config = require("conjure.config")
vim.g["conjure#mapping#doc_word"] = "gk"
vim.g["conjure#client#clojure#nrepl#mapping#session_clone"] = "sC"
vim.g["conjure#extract#tree_sitter#enabled"] = true
conjure_config["assoc-in"]({"filetypes"}, core.concat(conjure_config.filetypes(), {"markdown"}))
return conjure_config["assoc-in"]({"filetype", "markdown"}, "conjure.client.clojure.nrepl")

View File

@@ -0,0 +1,2 @@
-- [nfnl] fnl/dotfiles/plugin/dadbodui.fnl

View File

@@ -0,0 +1,3 @@
-- [nfnl] fnl/dotfiles/plugin/easyalign.fnl
local util = require("dotfiles.util")
return util.noremap("v", "<leader><bslash>", "EasyAlign*<Bar>")

View File

@@ -0,0 +1,11 @@
-- [nfnl] fnl/dotfiles/plugin/fugitive.fnl
local util = require("dotfiles.util")
local function bufmap(mode, from, to)
return util.noremap(mode, from, to, {["local?"] = true})
end
local function map_fugitive_keys()
bufmap("n", "<leader>gp", ":Git pull<CR>")
bufmap("n", "<leader>gP", ":Git push<CR>")
return bufmap("n", "<leader>gF", ":Git push -f<CR>")
end
return vim.api.nvim_create_autocmd({"FileType"}, {pattern = "fugitive", callback = map_fugitive_keys})

View File

@@ -0,0 +1,3 @@
-- [nfnl] fnl/dotfiles/plugin/headlines.fnl
local headlines = require("headlines")
return nil

View File

@@ -0,0 +1,7 @@
-- [nfnl] fnl/dotfiles/plugin/hex.fnl
local hex = require("hex")
if hex then
return hex.setup()
else
return nil
end

View File

@@ -0,0 +1,94 @@
-- [nfnl] fnl/dotfiles/plugin/lspconfig.fnl
local a = require("nfnl.core")
local u = require("dotfiles.util")
local lsp = require("vim.lsp")
local lspconfig = require("lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local function bufmap(mode, from, to)
return u.noremap(mode, from, to, {["local?"] = true})
end
local function nbufmap(from, to)
return bufmap("n", from, to)
end
local function xbufmap(from, to)
return bufmap("x", from, to)
end
vim.diagnostic.config({signs = {text = {[vim.diagnostic.severity.ERROR] = "\226\152\162\239\184\143", [vim.diagnostic.severity.WARN] = "\226\154\160\239\184\143", [vim.diagnostic.severity.INFO] = "\226\132\185\239\184\143", [vim.diagnostic.severity.HINT] = "\240\159\148\142"}}})
local core_nmappings = {gd = "lua vim.lsp.buf.definition()", gD = "lua vim.lsp.buf.declaration()", gi = "lua vim.lsp.buf.implementation()", gr = "lua vim.lsp.buf.references()", K = "lua vim.lsp.buf.hover()", ["[g"] = "lua vim.diagnostic.goto_prev()", ["]g"] = "lua vim.diagnostic.goto_next()", ["<leader>ca"] = "lua vim.lsp.buf.code_action()", ["<leader>cl"] = "lua vim.lsp.codelens.run()", ["<leader>ic"] = "lua vim.lsp.buf.incoming_calls()", ["<leader>sld"] = "lua vim.diagnostic.open_float(nil, {source = 'always'})", ["<leader>rn"] = "lua vim.lsp.buf.rename()", ["<leader>fa"] = "lua vim.lsp.buf.format()"}
local client_nmappings = {clojure_lsp = {["<leader>cn"] = "call LspExecuteCommand('clean-ns')", ["<leader>ref"] = "call LspExecuteCommand('extract-function', input('Function name: '))", ["<leader>id"] = "call LspExecuteCommand('inline-symbol')", ["<leader>il"] = "call LspExecuteCommand('introduce-let', input('Binding name: '))", ["<leader>m2l"] = "call LspExecuteCommand('move-to-let', input('Binding name: '))"}}
local client_command_lnmappings = {clojure_lsp = {ai = {"add-import-to-namespace", {"input('Namespace name: ')"}}, am = {"add-missing-libspec", {}}, as = {"add-require-suggestion", {"input('Namespace name: ')", "input('Namespace as: ')", "input('Namespace name: ')"}}, cc = {"cycle-coll", {}}, cn = {"clean-ns", {}}, cp = {"cycle-privacy", {}}, ct = {"create-test", {}}, df = {"drag-forward", {}}, db = {"drag-backward", {}}, dk = {"destructure-keys", {}}, ed = {"extract-to-def", {"input('Definition name: ')"}}, ef = {"extract-function", {"input('Function name: ')"}}, el = {"expand-let", {}}, fe = {"create-function", {}}, il = {"introduce-let", {"input('Binding name: ')"}}, is = {"inline-symbol", {}}, ma = {"resolve-macro-as", {}}, mf = {"move-form", {"input('File name: ')"}}, ml = {"move-to-let", {"input('Binding name: ')"}}, pf = {"promote-fn", {"input('Function name: ')"}}, sc = {"change-collection", {"input('Collection type: ')"}}, sm = {"sort-map", {}}, tf = {"thread-first-all", {}}, tF = {"thread-first", {}}, tl = {"thread-last-all", {}}, tL = {"thread-last", {}}, ua = {"unwind-all", {}}, uw = {"unwind-thread", {}}}}
local server_specific_opts = {}
local function bind_client_mappings(client)
local client_name = a.get(client, "name")
local mappings = a.get(client_nmappings, client_name)
local command_lnmappings = a.get(client_command_lnmappings, client_name)
if mappings then
for mapping, cmd in pairs(mappings) do
nbufmap(mapping, cmd)
end
else
end
if command_lnmappings then
for lnmapping, command_mapping in pairs(command_lnmappings) do
local lsp_cmd = a.first(command_mapping)
local opts_str
do
local s = ""
for i, opt in ipairs(a.second(command_mapping)) do
s = (s .. ", " .. opt)
end
opts_str = s
end
local mapping = ("<leader>" .. lnmapping)
local cmd = ("call LspExecuteCommand('" .. lsp_cmd .. "'" .. opts_str .. ")")
nbufmap(mapping, cmd)
end
return nil
else
return nil
end
end
local function on_attach(client, bufnr)
for mapping, cmd in pairs(core_nmappings) do
nbufmap(mapping, cmd)
end
xbufmap("<leader>fa", "lua vim.lsp.buf.format()")
vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", {buf = 0})
bind_client_mappings(client)
if client.server_capabilities.documentFormattingProvider then
local function _3_()
return vim.lsp.buf.format()
end
vim.api.nvim_create_autocmd({"BufWritePre"}, {pattern = "<buffer>", callback = _3_})
else
end
return print("LSP Client Attached.")
end
local base_server_opts
do
local capabilities = cmp_nvim_lsp.default_capabilities(lsp.protocol.make_client_capabilities())
base_server_opts = {on_attach = on_attach, capabilities = capabilities, flags = {debounce_text_changes = 150}}
end
local function default_server_handler(server_name)
local specific_opts = a.get(server_specific_opts, server_name, {})
local server_opts = a.merge(base_server_opts, specific_opts)
return vim.lsp.config(server_name, server_opts)
end
local function lsp_execute_command(cmd, ...)
local buf_uri = vim.uri_from_bufnr(0)
local cursor = vim.api.nvim_win_get_cursor(0)
local r = (a.first(cursor) - 1)
local c = a.second(cursor)
local opts = {buf_uri, r, c}
local args = a.concat(opts, {...})
return vim.lsp.buf.execute_command({command = cmd, arguments = args})
end
local function setup_handlers(language_servers)
for _, server_name in pairs(language_servers) do
default_server_handler(server_name)
end
return nil
end
u.nnoremap("<leader>li", "LspInfo")
vim.api.nvim_create_user_command("LspExecuteCommand", lsp_execute_command, {})
return {on_attach = on_attach, ["default-server-handler"] = default_server_handler, ["setup-handlers"] = setup_handlers}

View File

@@ -0,0 +1,32 @@
-- [nfnl] fnl/dotfiles/plugin/luasnip.fnl
local luasnip = require("luasnip")
local select_choice = require("luasnip.extras.select_choice")
if luasnip then
local function _1_()
if luasnip.expand_or_jumpable() then
return luasnip.expand_or_jump()
else
return nil
end
end
vim.keymap.set({"i", "s"}, "<C-k>", _1_, {silent = true})
local function _3_()
if luasnip.jumpable(-1) then
return luasnip.jump(-1)
else
return nil
end
end
vim.keymap.set({"i", "s"}, "<C-j>", _3_, {silent = true})
local function _5_()
if luasnip.choice_active() then
return luasnip.choice(1)
else
return nil
end
end
vim.keymap.set("i", "<C-l>", _5_)
return vim.keymap.set("i", "<C-u>", select_choice)
else
return nil
end

View File

@@ -0,0 +1,14 @@
-- [nfnl] fnl/dotfiles/plugin/mason.fnl
local mason = require("mason")
local mason_lspconf = require("mason-lspconfig")
local lspconfig = require("dotfiles.plugin.lspconfig")
local function setup()
mason.setup({ui = {icons = {package_installed = "\226\156\147"}}})
if mason_lspconf then
mason_lspconf.setup({ensure_installed = {"lua_ls"}, automatic_enable = true})
return lspconfig["setup-handlers"](mason_lspconf.get_installed_servers())
else
return nil
end
end
return setup()

View File

@@ -0,0 +1,3 @@
-- [nfnl] fnl/dotfiles/plugin/nfnl.fnl
local nfnl = require("nfnl")
return nfnl.setup({compile_on_write = true})

View File

@@ -0,0 +1,9 @@
-- [nfnl] fnl/dotfiles/plugin/null-ls.fnl
local null_ls = require("null-ls")
local lspconfig = require("dotfiles.plugin.lspconfig")
if null_ls then
local null_ls_server_options = {sources = {null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.fnlfmt}, on_attach = lspconfig.on_attach}
return null_ls.setup(null_ls_server_options)
else
return nil
end

View File

@@ -0,0 +1,41 @@
-- [nfnl] fnl/dotfiles/plugin/orgbullets.fnl
local core = require("nfnl.core")
local conceal = require("dotfiles.conceal")
local ts_utils = require("dotfiles.ts-utils")
local stars = {"\226\151\137", "\226\166\190", "\226\151\139", "\226\156\184", "\226\156\191", "\226\156\182", "\226\128\162", "\226\128\163"}
local stars_query = "(headline (stars) @stars)"
local function star_index(heading_level)
local star_count = core.count(stars)
local idx = math.fmod(heading_level, star_count)
if (0 < idx) then
return idx
else
return star_count
end
end
local extmark_namespace = vim.api.nvim_create_namespace("HeaderStars")
local star_captures = ts_utils["make-query"]("org", stars_query)
local function gen_star_extmarks()
if ("org" == vim.bo.filetype) then
local bufnr = vim.api.nvim_get_current_buf()
local star_count = core.count(stars)
vim.api.nvim_buf_clear_namespace(bufnr, extmark_namespace, 0, -1)
for id, node, metadata in star_captures(bufnr) do
local start_line,start_col,end_row,end_col = node:range()
local heading_level
if (start_line == end_row) then
heading_level = (end_col - start_col)
else
heading_level = nil
end
local star = core.get(stars, star_index(heading_level))
local replacement = string.format(core.str("%", (2 + heading_level), "s"), star)
vim.api.nvim_buf_set_extmark(bufnr, extmark_namespace, start_line, start_col, {end_col = end_col, end_row = end_row, virt_text = {{replacement, {}}}, virt_text_pos = "overlay", hl_mode = "combine"})
end
return nil
else
return nil
end
end
local group = vim.api.nvim_create_augroup("HeaderStars", {clear = true})
return vim.api.nvim_create_autocmd({"FileChangedShellPost", "Syntax", "TextChanged", "InsertLeave", "WinScrolled"}, {group = group, callback = conceal["setup-conceals"]})

View File

@@ -0,0 +1,4 @@
-- [nfnl] fnl/dotfiles/plugin/orgmode.fnl
local orgmode = require("orgmode")
orgmode.setup({org_agenda_files = {"~/Dropbox/org/*", "~/my-orgs/**/*"}, org_default_notes_file = "~/Dropbox/org/refile.org", mappings = {org = {org_toggle_checkbox = "<C-.>"}}})
return require("dotfiles.plugin.orgbullets")

View File

@@ -0,0 +1,4 @@
-- [nfnl] fnl/dotfiles/plugin/packer.fnl
local u = require("dotfiles.util")
u.nnoremap("<leader>pi", "PackerInstall")
return u.nnoremap("<leader>pu", "PackerUpdate")

View File

@@ -0,0 +1,93 @@
-- [nfnl] fnl/dotfiles/plugin/paredit.fnl
local a = require("nfnl.core")
local treesitter = require("dotfiles.plugin.treesitter")
local ts_parsers = require("nvim-treesitter.parsers")
local ts_utils = require("nvim-treesitter.ts_utils")
local languagetree = require("vim.treesitter.languagetree")
vim.g.paredit_smartjump = 1
local function list_member_3f(xs, x)
local function _1_(_241)
return (x == _241)
end
return a.some(_1_, a.vals(xs))
end
local function bool__3eint(bool)
if bool then
return 1
else
return 0
end
end
local function int__3ebool(x)
if (0 == x) then
return false
else
return true
end
end
local function toggle_global_21(x)
vim.g[x] = bool__3eint(not int__3ebool(a.get(vim.g, x)))
return nil
end
local function language_at_cursor()
local parser = ts_parsers.get_parser()
local current_node = ts_utils.get_node_at_cursor()
local range
if current_node then
range = {current_node:range()}
else
range = nil
end
local lang
if range then
lang = languagetree.language_for_range(parser, range)
else
lang = nil
end
if lang then
return lang:lang()
else
return nil
end
end
local function parser_language()
local parser = ts_parsers.get_parser()
if parser then
return parser:lang()
else
return nil
end
end
local paredit_langs = {"clojure", "fennel", "hy", "janet", "julia", "lfe", "lisp", "racket", "scheme", "shen"}
local paredit_host_langs = {"org", "markdown", "asciidoc"}
local function host_lang_in_3f(langs)
return list_member_3f(langs, parser_language())
end
local function paredit_lang_3f(lang)
return list_member_3f(paredit_langs, lang)
end
local function TreeSitterLangParedit()
if host_lang_in_3f(paredit_host_langs) then
local cursor_lang = language_at_cursor()
if cursor_lang then
vim.g.paredit_mode = bool__3eint(paredit_lang_3f(cursor_lang))
return vim.fn.PareditInitBuffer()
else
return nil
end
else
return nil
end
end
local function _10_()
return vim.fn.PareditInitBalancingAllBracketsBuffer()
end
vim.api.nvim_create_autocmd({"FileType"}, {pattern = "ruby", callback = _10_})
local function _11_()
return vim.fn.PareditInitBalancingAllBracketsBuffer()
end
vim.api.nvim_create_autocmd({"FileType"}, {pattern = "javascript", callback = _11_})
local function _12_()
return vim.fn.PareditInitBalancingAllBracketsBuffer()
end
return vim.api.nvim_create_autocmd({"FileType"}, {pattern = "terraform", callback = _12_})

View File

@@ -0,0 +1,19 @@
-- [nfnl] fnl/dotfiles/plugin/smartsplits.fnl
local smart_splits = require("smart-splits")
if smart_splits then
smart_splits.setup()
vim.keymap.set("n", "<M-S-h>", smart_splits.resize_left)
vim.keymap.set("n", "<M-S-j>", smart_splits.resize_down)
vim.keymap.set("n", "<M-S-k>", smart_splits.resize_up)
vim.keymap.set("n", "<M-S-l>", smart_splits.resize_right)
vim.keymap.set("n", "<M-h>", smart_splits.move_cursor_left)
vim.keymap.set("n", "<M-j>", smart_splits.move_cursor_down)
vim.keymap.set("n", "<M-k>", smart_splits.move_cursor_up)
vim.keymap.set("n", "<M-l>", smart_splits.move_cursor_right)
vim.keymap.set("n", "<leader><leader>h", smart_splits.swap_buf_left)
vim.keymap.set("n", "<leader><leader>j", smart_splits.swap_buf_down)
vim.keymap.set("n", "<leader><leader>k", smart_splits.swap_buf_up)
return vim.keymap.set("n", "<leader><leader>l", smart_splits.swap_buf_right)
else
return nil
end

View File

@@ -0,0 +1,28 @@
-- [nfnl] fnl/dotfiles/plugin/telescope.fnl
local util = require("dotfiles.util")
local telescope = require("telescope")
local vimgrep_arguments = {"ag", "--nocolor", "--noheading", "--number", "--column", "--nobreak", "--smart-case", "--hidden", "--ignore", ".git", "--follow"}
telescope.load_extension("projects")
telescope.load_extension("yank_history")
telescope.setup({pickers = {buffers = {mappings = {n = {d = "delete_buffer"}}}}, extensions = {projects = {projects = {}}}})
util.lnnoremap("fc", "Telescope commands")
util.lnnoremap("fC", "Telescope command_history")
util.lnnoremap("ff", "Telescope git_files hidden=true")
util.lnnoremap("f-", "Telescope find_files")
util.lnnoremap("fg", "Telescope live_grep")
util.lnnoremap("*", "Telescope grep_string")
util.lnnoremap("fb", "Telescope buffers")
util.lnnoremap("fd", "Telescope diagnostics")
util.lnnoremap("fH", "Telescope help_tags")
util.lnnoremap("fh", "Telescope oldfiles")
util.lnnoremap("fp", "Telescope projects")
util.lnnoremap("fm", "Telescope keymaps")
util.lnnoremap("fM", "Telescope marks")
util.lnnoremap("ft", "Telescope filetypes")
util.lnnoremap("fq", "Telescope quickfix")
util.lnnoremap("fl", "Telescope loclist")
util.lnnoremap("fsi", "Telescope lsp_implementations")
util.lnnoremap("fsr", "Telescope lsp_references")
util.lnnoremap("fsS", "Telescope lsp_document_symbols")
util.lnnoremap("fss", "Telescope lsp_workspace_symbols")
return util.lnnoremap("fy", "Telescope yank_history")

View File

@@ -0,0 +1,14 @@
-- [nfnl] fnl/dotfiles/plugin/toggleterm.fnl
local toggleterm = require("toggleterm")
toggleterm.setup({open_mapping = "<c-\\>", start_in_insert = true, insert_mappings = true, terminal_mappings = true, persist_size = true, persist_mode = true, autochdir = true})
local function set_terminal_keymaps()
vim.keymap.set("t", "<esc>", "<C-\\><C-n>")
vim.keymap.set("t", "jk", "<C-\\><C-n>")
vim.keymap.set("t", "<C-h>", "<Cmd>wincmd h<CR>")
vim.keymap.set("t", "<C-j>", "<Cmd>wincmd j<CR>")
vim.keymap.set("t", "<C-k>", "<Cmd>wincmd k<CR>")
vim.keymap.set("t", "<C-l>", "<Cmd>wincmd l<CR>")
return vim.keymap.set("t", "<C-w>", "<C-\\><C-n><C-w>")
end
vim.api.nvim_create_user_command("SetTerminalKeymaps", set_terminal_keymaps, {})
return vim.api.nvim_create_autocmd({"TermOpen"}, {pattern = "term://*", callback = set_terminal_keymaps})

View File

@@ -0,0 +1,3 @@
-- [nfnl] fnl/dotfiles/plugin/treesitter.fnl
local treesitter_configs = require("nvim-treesitter.configs")
return treesitter_configs.setup({highlight = {enable = true, additional_vim_regex_highlighting = {"org"}}, ensure_installed = "all", rainbow = {enable = true, extended_mode = true, max_file_lines = 10000, colors = {"#dc322f", "#b58900", "#d33682", "#859900", "#2aa198", "#268bd2", "#6c71c4"}}})

View File

@@ -0,0 +1,7 @@
-- [nfnl] fnl/dotfiles/plugin/whichkey.fnl
local which_key = require("which-key")
if which_key then
return which_key.setup({})
else
return nil
end

View File

@@ -0,0 +1,23 @@
-- [nfnl] fnl/dotfiles/plugin/yanky.fnl
local yanky = require("yanky")
yanky.setup({ring = {history_length = 100, storage = "shada", sync_with_numbered_registers = true, cancel_event = "update"}, system_clipboard = {sync_with_ring = true}})
vim.keymap.set("n", "p", "<Plug>(YankyPutAfter)")
vim.keymap.set("n", "P", "<Plug>(YankyPutBefore)")
vim.keymap.set("n", "gp", "<Plug>(YankyGPutAfter)")
vim.keymap.set("n", "gP", "<Plug>(YankyGPutBefore)")
vim.keymap.set("n", "<c-n>", "<Plug>(YankyCycleForward)")
vim.keymap.set("n", "<c-p>", "<Plug>(YankyCycleBackward)")
vim.keymap.set("n", "]p", "<Plug>(YankyPutIndentAfterLinewise)")
vim.keymap.set("n", "[p", "<Plug>(YankyPutIndentBeforeLinewise)")
vim.keymap.set("n", "]P", "<Plug>(YankyPutIndentAfterLinewise)")
vim.keymap.set("n", "[P", "<Plug>(YankyPutIndentBeforeLinewise)")
vim.keymap.set("n", ">p", "<Plug>(YankyPutIndentAfterShiftRight)")
vim.keymap.set("n", "<p", "<Plug>(YankyPutIndentAfterShiftLeft)")
vim.keymap.set("n", ">P", "<Plug>(YankyPutIndentBeforeShiftRight)")
vim.keymap.set("n", "<P", "<Plug>(YankyPutIndentBeforeShiftLeft)")
vim.keymap.set("n", "=p", "<Plug>(YankyPutAfterFilter)")
vim.keymap.set("n", "=P", "<Plug>(YankyPutBeforeFilter)")
vim.keymap.set("x", "p", "<Plug>(YankyPutAfter)")
vim.keymap.set("x", "P", "<Plug>(YankyPutBefore)")
vim.keymap.set("x", "gp", "<Plug>(YankyGPutAfter)")
return vim.keymap.set("x", "gP", "<Plug>(YankyGPutBefore)")

View File

@@ -0,0 +1,29 @@
-- [nfnl] fnl/dotfiles/plugins.fnl
local packer = require("packer")
local core = require("nfnl.core")
local function safe_require_plugin_config(name)
local ok_3f, val_or_err = pcall(require, ("dotfiles.plugin." .. name))
if not ok_3f then
return print(("dotfiles error: " .. val_or_err))
else
return nil
end
end
local function use(pkgs)
local function _2_(use0)
for name, opts in pairs(pkgs) do
do
local tmp_3_ = opts.mod
if (nil ~= tmp_3_) then
safe_require_plugin_config(tmp_3_)
else
end
end
use0(core.assoc(opts, 1, name))
end
return nil
end
return packer.startup(_2_)
end
local packages = {["Olical/nfnl"] = {}, ["Olical/conjure"] = {mod = "conjure"}, ["Olical/fennel.vim"] = {}, ["ahmedkhalf/project.nvim"] = {}, ["airblade/vim-gitgutter"] = {}, ["akinsho/toggleterm.nvim"] = {mod = "toggleterm"}, ["clojure-vim/vim-jack-in"] = {}, ["christianrondeau/vim-base64"] = {}, ["dhruvasagar/vim-table-mode"] = {}, ["folke/lsp-colors.nvim"] = {}, ["folke/which-key.nvim"] = {mod = "whichkey"}, ["gbprod/yanky.nvim"] = {mod = "yanky"}, ["hashivim/vim-terraform"] = {}, ["HiPhish/rainbow-delimiters.nvim"] = {}, ["hrsh7th/nvim-cmp"] = {requires = {"hrsh7th/cmp-buffer", "hrsh7th/cmp-emoji", "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lua", "hrsh7th/cmp-path", "hrsh7th/cmp-vsnip", "hrsh7th/vim-vsnip-integ", "L3MON4D3/LuaSnip", "PaterJason/cmp-conjure", "saadparwaiz1/cmp_luasnip"}, mod = "cmp"}, ["hrsh7th/vim-vsnip"] = {}, ["hrsh7th/vim-vsnip-integ"] = {}, ["Iron-E/nvim-soluarized"] = {}, ["jiangmiao/auto-pairs"] = {}, ["nvimtools/none-ls.nvim"] = {mod = "null-ls", requires = {"nvim-lua/plenary.nvim"}}, ["junegunn/vim-easy-align"] = {mod = "easyalign"}, ["kovisoft/paredit"] = {mod = "paredit", require = {"nvim-treesitter/nvim-treesitter"}}, ["kristijanhusak/vim-dadbod-completion"] = {}, ["kristijanhusak/vim-dadbod-ui"] = {}, ["L3MON4D3/LuaSnip"] = {mod = "luasnip"}, ["lifepillar/vim-solarized8"] = {}, ["lukas-reineke/headlines.nvim"] = {mod = "headlines"}, ["mrjones2014/smart-splits.nvim"] = {mod = "smartsplits"}, ["mechatroner/rainbow_csv"] = {}, ["MunifTanjim/nui.nvim"] = {}, ["neovim/nvim-lspconfig"] = {mod = "lspconfig"}, ["norcalli/nvim-colorizer.lua"] = {mod = "colorizer"}, ["nvim-neo-tree/neo-tree.nvim"] = {branch = "v3.x", require = {"nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", "MunifTanjim/nui.nvim"}}, ["nvim-orgmode/orgmode"] = {mod = "orgmode"}, ["nvim-telescope/telescope.nvim"] = {requires = {{"nvim-lua/popup.nvim"}, {"nvim-lua/plenary.nvim"}}, mod = "telescope"}, ["nvim-tree/nvim-web-devicons"] = {}, ["nvim-treesitter/nvim-treesitter"] = {run = ":TSUpdate", mod = "treesitter"}, ["nvim-treesitter/playground"] = {}, ["radenling/vim-dispatch-neovim"] = {}, ["RaafatTurki/hex.nvim"] = {mod = "hex"}, ["rafamadriz/friendly-snippets"] = {}, ["skywind3000/asyncrun.vim"] = {}, ["tpope/vim-dadbod"] = {}, ["tpope/vim-dispatch"] = {}, ["tpope/vim-fugitive"] = {mod = "fugitive"}, ["tpope/vim-git"] = {}, ["tpope/vim-pathogen"] = {}, ["tpope/vim-rails"] = {}, ["tpope/vim-repeat"] = {}, ["tpope/vim-rhubarb"] = {}, ["tpope/vim-surround"] = {}, ["tpope/vim-unimpaired"] = {}, ["tpope/vim-vinegar"] = {}, ["wbthomason/packer.nvim"] = {mod = "packer"}, ["williamboman/mason.nvim"] = {mod = "mason", requires = {"williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig"}}}
return use(packages)

View File

@@ -0,0 +1,10 @@
-- [nfnl] fnl/dotfiles/terraform-helpers.fnl
local function append_to_buf(bufno, lines)
if lines then
return vim.aip.nvim_buf_set_lines(bufno, -1, -1, false, lines)
else
return nil
end
end
local tf_log_bufno = nil
return nil

View File

@@ -0,0 +1,17 @@
-- [nfnl] fnl/dotfiles/ts-utils.fnl
local core = require("nfnl.core")
local function root(bufnr, lang)
local parser = vim.treesitter.get_parser(bufnr, lang, {})
local tree = core.first(parser:parse())
return tree:root()
end
local function make_query(lang, query_string)
local query = vim.treesitter.query.parse(lang, "(headline (stars) @stars)")
local function _1_(bufnr)
local root_node = root(bufnr, lang)
local iter_captures = query.iter_captures(query, root_node, bufnr, 0, -1)
return iter_captures
end
return _1_
end
return {root = root, ["make-query"] = make_query}

View File

@@ -0,0 +1,34 @@
-- [nfnl] fnl/dotfiles/util.fnl
local a = require("nfnl.core")
local function noremap(mode, from, to, opts)
local map_opts = {noremap = true, silent = true}
local to0 = (":" .. to .. "<cr>")
local buff_num = a.get(opts, "buff-num")
if (a.get(opts, "local?") or buff_num) then
return vim.api.nvim_buf_set_keymap((buff_num or 0), mode, from, to0, map_opts)
else
return vim.api.nvim_set_keymap(mode, from, to0, map_opts)
end
end
local function nnoremap(from, to, opts)
return noremap("n", from, to, opts)
end
local function tnoremap(from, to, opts)
return noremap("t", from, to, opts)
end
local function inoremap(from, to, opts)
return noremap("i", from, to, opts)
end
local function vnoremap(from, to, opts)
return noremap("v", from, to, opts)
end
local function lnnoremap(from, to)
return nnoremap(("<leader>" .. from), to)
end
local function ltnoremap(from, to, opts)
return noremap("v", ("<leader>" .. from), to, opts)
end
local function lvnoremap(from, to, opts)
return noremap("t", ("<leader>" .. from), to, opts)
end
return {noremap = noremap, nnoremap = nnoremap, tnoremap = tnoremap, inoremap = inoremap, vnoremap = vnoremap, lnnoremap = lnnoremap, ltnoremap = ltnoremap, lvnoremap = lvnoremap}

View File

@@ -0,0 +1,17 @@
-- [nfnl] fnl/dotfiles/zoom-toggle.fnl
local u = require("dotfiles.util")
local unzoom_21 = nil
local function zoom_toggle()
if unzoom_21 then
vim.cmd(unzoom_21)
unzoom_21 = nil
return nil
else
unzoom_21 = vim.fn.winrestcmd()
vim.fn.resize()
return vim.fn.vertical("resize")
end
end
vim.api.nvim_create_user_command("ZoomToggle", zoom_toggle, {})
u.nnoremap("<M-z>", ":call ZoomToggle()<CR>")
return u.tnoremap("<M-z>", "<c-\\><c-n>:call ZoomToggle()<CR>")