From 80f4fbcb61fc0de125b07c0c6b4dd990d593a206 Mon Sep 17 00:00:00 2001 From: Craige McWhirter Date: Mon, 7 Mar 2022 23:57:33 +1000 Subject: [PATCH] neovim: switched to treefmt --- default.nix | 3 +++ profiles/neovim.nix | 42 +++++++++++++++++++++++++++++++++--------- treefmt.toml | 3 +++ 3 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 treefmt.toml diff --git a/default.nix b/default.nix index a08eb46..635c13a 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,16 @@ { sources ? import ./nix/sources.nix, system ? builtins.currentSystem , crossSystem ? null, config ? { } +, alejandraUnstable ? (import sources.nixpkgsUnstable { }).alejandra , cardanoNodeProject ? import sources.cardano-node { } }@args: with import ./nix args; { shell = mkShell { inherit (import sources.niv { }) niv; buildInputs = [ + alejandraUnstable # The Uncompromising Nix Code Formatter cardanoNodeProject.cardano-cli # required for KES key rotation niv nixopsUnstable # work around for issue #127423 + treefmt # one CLI to format the code tree ]; NIX_PATH = "nixpkgs=${sources.nixpkgs}"; NIXOPS_DEPLOYMENT = "${globals.deploymentName}"; diff --git a/profiles/neovim.nix b/profiles/neovim.nix index 32a6da1..fd8a2bd 100644 --- a/profiles/neovim.nix +++ b/profiles/neovim.nix @@ -10,12 +10,12 @@ start = [ airline # Lean & mean status/tabline for vim that's light as air dracula-vim # Dracula theme for vim + formatter-nvim # A format runner for neovim fugitive # Vim Git wrapper fzf-vim # Full path fuzzy file, buffer, mru, tag, finder for Vim haskell-vim # Syntax Highlighting and Indentation for Haskell indentLine # Display thin vertical lines at each indentation level neocomplete-vim # Keyword completion system - neoformat # A (Neo)vim plugin for formatting code. nerdcommenter # Comment functions so powerful—no comment necessary nerdtree # File system explorer nerdtree-git-plugin # Plugin for nerdtree showing git status @@ -23,7 +23,6 @@ supertab # Allows you to use for all your insert completion syntastic # Syntax checking hacks vim-addon-nix # Scripts assisting writing .nix files - vim-autoformat # Automatically format code vim-cue # Cue filetype plugin for Vim vim-lastplace vim-markdown-toc # Generate table of contents for Markdown files @@ -88,7 +87,11 @@ autocmd FileAppendPre * :call TrimWhiteSpace() autocmd FilterWritePre * :call TrimWhiteSpace() autocmd BufWritePre * :call TrimWhiteSpace() - "autocmd BufWrite * :Autoformat + + augroup FormatAutogroup + autocmd! + autocmd BufWritePost * silent! FormatWrite + augroup END " FIXME: Currently always set to dark due to issues with Termonad Solarized theme " Light during the day, dark during the night @@ -128,12 +131,6 @@ autocmd BufWritePost,FileWritePost *.gpg u augroup END - " Use Neoformat to automatically format files - augroup fmt - autocmd! - autocmd BufWritePre * undojoin | Neoformat - augroup END - " Manage ISO files augroup iso au! @@ -301,6 +298,33 @@ set spell! endfunction autocmd BufNewFile,BufFilePre,BufRead *.sh :call BashSettings() + + lua <