From cb69c5bc98114ccb0433d693fa22fc705d090b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Niemier?= <~@hauleth.dev> Date: Mon, 2 Sep 2024 12:15:14 +0200 Subject: [PATCH] fix: various NeoVim configuration issues --- modules/nvim.nix | 73 +++++++++++++++++++--- vim/.config/nvim/fnl/nvim/macro-init.fnl | 6 +- vim/.config/nvim/fnl/relude/macro-init.fnl | 8 +-- vim/.config/nvim/init.fnl | 17 +++-- 4 files changed, 84 insertions(+), 20 deletions(-) diff --git a/modules/nvim.nix b/modules/nvim.nix index 0633355..79d390f 100644 --- a/modules/nvim.nix +++ b/modules/nvim.nix @@ -18,15 +18,72 @@ require('basic') EOF ''; - packages.vimPackages = with pkgs.vimPlugins; { + packages.vimPackages = let + plugins = pkgs.vimPlugins; + ts = plugins.nvim-treesitter.withPlugins ( + g: [ + g.bibtex + g.comment + g.cpp + g.css + g.csv + g.dhall + g.diff + g.djot + g.dot + g.editorconfig + g.eex + g.elixir + g.erlang + g.fennel + g.fish + g.git_config + g.git_rebase + g.gitattributes + g.gitcommit + g.glsl + g.graphql + g.haskell + g.haskell_persistent + g.hcl + g.heex + g.html + g.javascript + g.jq + g.json + g.julia + g.just + g.make + g.mermaid + g.nickel + g.nix + g.po + g.printf + g.prolog + g.racket + g.regex + g.robots + g.ruby + g.rust + g.scheme + g.sql + g.ssh_config + g.terraform + g.toml + g.typescript + g.typst + g.yaml + g.zig + ] + ); + in { start = [ - packer-nvim - nvim-treesitter.withAllGrammars - vim-nickel - # XXX: Currently broken - lua-utils-nvim - neorg - neorg-telescope + plugins.packer-nvim + plugins.vim-nickel + plugins.lua-utils-nvim + plugins.neorg + plugins.neorg-telescope + ts ]; opt = []; diff --git a/vim/.config/nvim/fnl/nvim/macro-init.fnl b/vim/.config/nvim/fnl/nvim/macro-init.fnl index c6ac011..443dab0 100644 --- a/vim/.config/nvim/fnl/nvim/macro-init.fnl +++ b/vim/.config/nvim/fnl/nvim/macro-init.fnl @@ -16,10 +16,12 @@ (fn augroup [name ...] "Define auto group" + (let [ast `(let [,(sym :au-id) (vim.api.nvim_create_augroup ,(view name) {:clear true})] (import-macros {: on} :nvim) - ,... - au-id)) + (do ,...) + au-id)] + ast)) ; TODO: Make argument passing more explicit and find another way to pass ; options. Example idea may be to parse argument list and translate them to the diff --git a/vim/.config/nvim/fnl/relude/macro-init.fnl b/vim/.config/nvim/fnl/relude/macro-init.fnl index ed435b6..4d9409b 100644 --- a/vim/.config/nvim/fnl/relude/macro-init.fnl +++ b/vim/.config/nvim/fnl/relude/macro-init.fnl @@ -1,16 +1,16 @@ (fn use [mod names] (assert-compile (sym? mod) "expected symbol" mod) (let [mod-name (view mod) - splitted (vim.split mod-name "." {:plain true}) - last (. splitted (length splitted)) + split (vim.split mod-name "." {:plain true}) + last (. split (length split)) matcher (if (= names nil) (sym last) names)] `(local ,matcher (require ,mod-name)))) (fn reuse [mod names] (assert-compile (sym? mod) "expected symbol" mod) (let [mod-name (view mod) - splitted (vim.split mod-name "." {:plain true}) - last (. splitted (length splitted)) + split (vim.split mod-name "." {:plain true}) + last (. split (length split)) matcher (if (= names nil) (sym last) names)] `(local ,matcher (do diff --git a/vim/.config/nvim/init.fnl b/vim/.config/nvim/init.fnl index c03871d..e54ed2b 100644 --- a/vim/.config/nvim/init.fnl +++ b/vim/.config/nvim/init.fnl @@ -71,15 +71,20 @@ (do ; Keep cursor in the middle - (let [value 9999] - (set opt.scrolloff value) - (augroup terminal-scrolloff - (on BufEnter "term://*" + (let [value 9999 + enter (fn [] + (cmd.echo "'hello'") (set opt.window.signcolumn :no) (set opt.window.scrolloff 0)) - (on BufLeave "term://*" + leave (fn [] + (cmd.echo "'bye'") (set opt.window.signcolumn "yes:1") - (set opt.window.scrolloff value))))) + (set opt.window.scrolloff value))] + (set opt.scrolloff value) + (augroup terminal-scrolloff + (on TermOpen "*" (enter)) + (on BufEnter "term://*" (enter)) + (on BufLeave "term://*" (leave))))) (do ; XXI century - we have cursors now (set opt.mouse :a)) -- 2.51.2