From d8c08728465ef5679d771f01d5ce84fb1ddb9096 Mon Sep 17 00:00:00 2001 From: Mike Vink Date: Mon, 21 Nov 2022 11:35:50 +0100 Subject: start moving stuff to fennel --- flake.lock | 18 +++++----- home.nix | 4 +-- neovim/fnl/conf/build-init.fnl | 0 neovim/fnl/conf/init.fnl | 10 ++++++ neovim/fnl/conf/macros.fnl | 24 +++++++++++++ neovim/fnl/conf/pkgs.fnl | 1 + neovim/fnl/conf/pkgs/cmp.fnl | 18 ++++++++++ neovim/fnl/conf/settings.fnl | 6 ++++ neovim/fnl/cookbook.fnl | 1 - neovim/fnl/macros.fnl | 24 ------------- neovim/init.fnl | 77 +++--------------------------------------- neovim/init.lua | 32 ++---------------- 12 files changed, 76 insertions(+), 139 deletions(-) create mode 100644 neovim/fnl/conf/build-init.fnl create mode 100644 neovim/fnl/conf/init.fnl create mode 100644 neovim/fnl/conf/macros.fnl create mode 100644 neovim/fnl/conf/pkgs.fnl create mode 100644 neovim/fnl/conf/pkgs/cmp.fnl create mode 100644 neovim/fnl/conf/settings.fnl delete mode 100644 neovim/fnl/cookbook.fnl delete mode 100644 neovim/fnl/macros.fnl diff --git a/flake.lock b/flake.lock index 35c231c..d0b843e 100644 --- a/flake.lock +++ b/flake.lock @@ -8,11 +8,11 @@ "utils": "utils" }, "locked": { - "lastModified": 1668332334, - "narHash": "sha256-YT1qcE/MCqBO1Bi/Yr6GcFpNKsvmzrBKh8juyXDbxQc=", + "lastModified": 1668788863, + "narHash": "sha256-FsdUG+YkRX7JZKZm6T44J2h+0pXB1sWA9AobyiozFK0=", "owner": "nix-community", "repo": "home-manager", - "rev": "bc90de24d898655542589237cc0a6ada7564cb6c", + "rev": "948d1f8a5cef55a281d4f5d17f3b79df6c82fce1", "type": "github" }, "original": { @@ -39,11 +39,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668417584, - "narHash": "sha256-yeuEyxKPwsm5fIHN49L/syn9g5coxnPp3GsVquhrv5A=", + "lastModified": 1668765800, + "narHash": "sha256-rC40+/W6Hio7b/RsY8SvQPKNx4WqNcTgfYv8cUMAvJk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "013fcdd106823416918004bb684c3c186d3c460f", + "rev": "52b2ac8ae18bbad4374ff0dd5aeee0fdf1aea739", "type": "github" }, "original": { @@ -55,11 +55,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1668459637, - "narHash": "sha256-HqnWCKujmtu8v0CjzOT0sr7m2AR7+vpbZJOp1R0rodY=", + "lastModified": 1668766498, + "narHash": "sha256-UjZlIrbHGlL3H3HZNPTxPSwJfr49jIfbPWCYxk0EQm4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "16f4e04658c2ab10114545af2f39db17d51bd1bd", + "rev": "f42a45c015f28ac3beeb0df360e50cdbf495d44b", "type": "github" }, "original": { diff --git a/home.nix b/home.nix index 7a0b82f..1c90dde 100644 --- a/home.nix +++ b/home.nix @@ -106,8 +106,8 @@ Flake = { lua_language_server = [[${pkgs.sumneko-lua-language-server}]], bash = [[${pkgs.bashInteractive}/bin/bash]] } -vim.opt.runtimepath:append({ [[~/dotnix/neovim]], [[~/dotnix/neovim/lua]] }) -package.path = [[/home/mike/dotnix/?/init.lua;]] .. [[/home/mike/.cache/nvim/hotpot/hotpot.nvim/lua/?/init.lua;]] .. package.path +vim.opt.runtimepath:append({ [[~/dotnix/neovim]], [[~/dotnix/neovim/lua]], [[~/dotnix/neovim/fnl]]}) +package.path = [[/home/mike/dotnix/?/init.lua;]] .. [[/home/mike/dotnix/?/?;]] .. [[/home/mike/.cache/nvim/hotpot/hotpot.nvim/lua/?/init.lua;]] .. package.path require'neovim' LUA "; diff --git a/neovim/fnl/conf/build-init.fnl b/neovim/fnl/conf/build-init.fnl new file mode 100644 index 0000000..e69de29 diff --git a/neovim/fnl/conf/init.fnl b/neovim/fnl/conf/init.fnl new file mode 100644 index 0000000..4d10062 --- /dev/null +++ b/neovim/fnl/conf/init.fnl @@ -0,0 +1,10 @@ +(tset (. vim "g") "mapleader" " ") +(tset (. vim "g") "maplocalleader" " ") + +(vim.cmd "colorscheme gruvbox-material") + +(let [ts (require :nvim-treesitter.configs)] + (ts.setup + {:highlight {:enable true}})) + +(require :conf.pkgs) diff --git a/neovim/fnl/conf/macros.fnl b/neovim/fnl/conf/macros.fnl new file mode 100644 index 0000000..fe10ed3 --- /dev/null +++ b/neovim/fnl/conf/macros.fnl @@ -0,0 +1,24 @@ +;; cannot be at the bottom? +(fn settings [...] + (fn echo [l] (each [k v (ipairs l)] (print k v))) + (fn tbl-echo [tbl] (collect [k v (pairs tbl)] (print k v) (values k v))) + + (fn stringify [l] (icollect [_ v (ipairs l)] (tostring v))) + + (fn kv [l tbl] + (let [[first second & rest] l] + (when (and (not= first nil) (not= second nil)) + (tset tbl first second) + (kv rest tbl)) + tbl)) + + (let [opts-tbl (-> [...] + (stringify) + (kv {}))] + `(each [k# v# (pairs ,opts-tbl)] + (match [k# v#] + [a# "true"] (tset (. vim "opt") k# true) + [a# "false"] (tset (. vim "opt") k# false) + [a# b#] (tset (. vim "opt") k# v#))))) + +{: settings} diff --git a/neovim/fnl/conf/pkgs.fnl b/neovim/fnl/conf/pkgs.fnl new file mode 100644 index 0000000..77b3e73 --- /dev/null +++ b/neovim/fnl/conf/pkgs.fnl @@ -0,0 +1 @@ +(require :conf.pkgs.cmp) diff --git a/neovim/fnl/conf/pkgs/cmp.fnl b/neovim/fnl/conf/pkgs/cmp.fnl new file mode 100644 index 0000000..c31cb02 --- /dev/null +++ b/neovim/fnl/conf/pkgs/cmp.fnl @@ -0,0 +1,18 @@ +(let [cmp (require :cmp) + luasnip (require :luasnip) + snip (fn [args] (luasnip.lsp_expand (. args :body)))] + + (cmp.setup + {:snippet {:expand snip} + :completion {:autocomplete false} + :mapping + (cmp.mapping.preset.insert + {"" (cmp.mapping.scroll_docs -4) + "" (cmp.mapping.scroll_docs 4) + "" (cmp.mapping.complete) + "" (cmp.mapping.confirm {:select true})}) + :sources (cmp.config.sources + [{:name :conjure} + {:name :nvim_lsp} + {:name :path} + {:name :luasnip}])})) diff --git a/neovim/fnl/conf/settings.fnl b/neovim/fnl/conf/settings.fnl new file mode 100644 index 0000000..580ec91 --- /dev/null +++ b/neovim/fnl/conf/settings.fnl @@ -0,0 +1,6 @@ +(import-macros { : settings} :conf.macros) +(settings + backup false + backupcopy yes + foldmarker "///,///") + diff --git a/neovim/fnl/cookbook.fnl b/neovim/fnl/cookbook.fnl deleted file mode 100644 index 12fc2f2..0000000 --- a/neovim/fnl/cookbook.fnl +++ /dev/null @@ -1 +0,0 @@ -(vim.cmd "echo 'hi'") diff --git a/neovim/fnl/macros.fnl b/neovim/fnl/macros.fnl deleted file mode 100644 index fe10ed3..0000000 --- a/neovim/fnl/macros.fnl +++ /dev/null @@ -1,24 +0,0 @@ -;; cannot be at the bottom? -(fn settings [...] - (fn echo [l] (each [k v (ipairs l)] (print k v))) - (fn tbl-echo [tbl] (collect [k v (pairs tbl)] (print k v) (values k v))) - - (fn stringify [l] (icollect [_ v (ipairs l)] (tostring v))) - - (fn kv [l tbl] - (let [[first second & rest] l] - (when (and (not= first nil) (not= second nil)) - (tset tbl first second) - (kv rest tbl)) - tbl)) - - (let [opts-tbl (-> [...] - (stringify) - (kv {}))] - `(each [k# v# (pairs ,opts-tbl)] - (match [k# v#] - [a# "true"] (tset (. vim "opt") k# true) - [a# "false"] (tset (. vim "opt") k# false) - [a# b#] (tset (. vim "opt") k# v#))))) - -{: settings} diff --git a/neovim/init.fnl b/neovim/init.fnl index cafa98e..878dff3 100644 --- a/neovim/init.fnl +++ b/neovim/init.fnl @@ -1,95 +1,26 @@ +;; Ahead of time compiles this file to ./init.lua (fn build-init [] (let [{: build} (require :hotpot.api.make) - ;; by default, Fennel wont perform strict global checking when - ;; compiling but we can force it to check by providing a list - ;; of allowed global names, this can catch some additional errors in - ;; this file. allowed-globals (icollect [n _ (pairs _G)] n) - opts {:verbosity 1 ;; set to 1 (or dont inclued the key) to see messages + opts {:verbosity 0 :compiler {:modules {:allowedGlobals allowed-globals}}}] - ;; just pass back the whole path as is (build "/home/mike/dotnix/neovim/init.fnl" opts ".+" #(values $1)))) +;; Call hotpot.setup and compile again after fs event (let [hotpot (require :hotpot) setup hotpot.setup build hotpot.api.make.build uv vim.loop] - ;; do some configuration stuff (setup {:provide_require_fennel true :compiler {:modules {:correlate true} :macros {:env :_COMPILER :compilerEnv _G :allowedGlobals false}}}) - ;; watch this file for changes and auto-rebuild on save (let [handle (uv.new_fs_event) - ;; uv wont accept condensed paths path (vim.fn.expand "/home/mike/dotnix/neovim/init.fnl")] - ;; note the vim.schedule call (uv.fs_event_start handle path {} #(vim.schedule build-init)) - ;; close the uv handle when we quit nvim (vim.api.nvim_create_autocmd :VimLeavePre {:callback #(uv.close handle)}))) -(import-macros { : settings} :macros) - -(tset (. vim "g") "mapleader" " ") -(tset (. vim "g") "maplocalleader" " ") - -(vim.cmd "colorscheme gruvbox-material") - -(settings - backup false - backupcopy yes) - -(let [ts (require :nvim-treesitter.configs)] - ((. ts :setup - {:highlight {:enable true}}))) - -(let [cmp (require :cmp) - snip (fn [args] ((. (require :luasnip) :lsp_expand) (. args :body)))] - ((. cmp :setup) - {:snippet {:expand snip} - :completion {:autocomplete false} - :mapping - (cmp.mapping.preset.insert - {"" (cmp.mapping.scroll_docs -4) - "" (cmp.mapping.complete)}) - :sources (cmp.config.sources - [{:name :conjure} - {:name :nvim_lsp} - {:name :path} - {:name :luasnip}])})) - - - - - -; {} -; snippet = {} -; -- REQUIRED - you must specify a snippet engine -; expand = function(args) -; require('luasnip').lsp_expand(args.body) -- For `luasnip` users. -; end, -; , -; completion = {} -; autocomplete = false -; , -; window = {} -; -- completion = cmp.config.window.bordered(), -; -- documentation = cmp.config.window.bordered(), -; , -; mapping = cmp.mapping.preset.insert({}) -; [''] = cmp.mapping.scroll_docs(-4), -; [''] = cmp.mapping.scroll_docs(4), -; [''] = cmp.mapping.complete(), -; [''] = cmp.mapping.abort(), -; [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. -; , -; sources = cmp.config.sources({}) -; { name = 'conjure' }, -; { name = 'nvim_lsp' }, -; { name = 'luasnip' }, -; { name = 'path' }, -; -; +(require :conf) diff --git a/neovim/init.lua b/neovim/init.lua index c8ca7ec..36ad398 100644 --- a/neovim/init.lua +++ b/neovim/init.lua @@ -15,7 +15,7 @@ local function build_init() end allowed_globals = tbl_17_auto end - local opts = {verbosity = 1, compiler = {modules = {allowedGlobals = allowed_globals}}} + local opts = {verbosity = 0, compiler = {modules = {allowedGlobals = allowed_globals}}} local function _3_(_241) return _241 end @@ -38,32 +38,4 @@ do end vim.api.nvim_create_autocmd("VimLeavePre", {callback = _5_}) end -vim.g["mapleader"] = " " -vim.g["maplocalleader"] = " " -vim.cmd("colorscheme gruvbox-material") -for k_7_auto, v_8_auto in pairs({backup = "false", backupcopy = "yes"}) do - local _6_ = {k_7_auto, v_8_auto} - if ((_G.type(_6_) == "table") and (nil ~= (_6_)[1]) and ((_6_)[2] == "true")) then - local a_9_auto = (_6_)[1] - vim.opt[k_7_auto] = true - elseif ((_G.type(_6_) == "table") and (nil ~= (_6_)[1]) and ((_6_)[2] == "false")) then - local a_9_auto = (_6_)[1] - vim.opt[k_7_auto] = false - elseif ((_G.type(_6_) == "table") and (nil ~= (_6_)[1]) and (nil ~= (_6_)[2])) then - local a_9_auto = (_6_)[1] - local b_10_auto = (_6_)[2] - vim.opt[k_7_auto] = v_8_auto - else - end -end -do - local ts = require("nvim-treesitter.configs") - ts.setup[{highlight = {enable = true}}]() -end -local cmp = require("cmp") -local snip -local function _8_(args) - return (require("luasnip")).lsp_expand(args.body) -end -snip = _8_ -return cmp.setup({snippet = {expand = snip}, completion = {autocomplete = false}, mapping = cmp.mapping.preset.insert({[""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.complete()}), sources = cmp.config.sources({{name = "conjure"}, {name = "nvim_lsp"}, {name = "path"}, {name = "luasnip"}})}) \ No newline at end of file +return require("conf") \ No newline at end of file -- cgit v1.2.3