From 4f0d32db753db660a2062578f67eb72e18dd634d Mon Sep 17 00:00:00 2001 From: tdro Date: Tue, 6 Jun 2023 18:20:46 -0400 Subject: .vim/vimrc: Update format programs Use emacs from vim with emacs-batch-indent to format lisp code --- .config/nixpkgs/config.nix | 12 ++++++--- .../packages/emacs-batch-indent/default.nix | 30 ++++++++++++++++++++++ .vim/vimrc | 24 +++++++++-------- 3 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 .config/nixpkgs/packages/emacs-batch-indent/default.nix diff --git a/.config/nixpkgs/config.nix b/.config/nixpkgs/config.nix index 70dc24f..20e78b5 100644 --- a/.config/nixpkgs/config.nix +++ b/.config/nixpkgs/config.nix @@ -27,7 +27,7 @@ in paths = [ Terminal Graphical Xorg Wayland Awesome Fonts Audio LaTeX Dictionary Android JavaScript Python PHP Lua Elixir HTML Shell Haskell Perl Nix C Golang Rust CSS - SQL YAML Ruby Nim Themes Emulators Clojure Lisp + SQL YAML HTTP Ruby Nim Themes Emulators Clojure Lisp ]; }; @@ -66,8 +66,9 @@ in paths = [ (import ./shells/larynx/shell.nix).fhs (import ./shells/larynx-server/shell.nix).fhs - (callPackage ./packages/hugo/default.nix { }) (callPackage ./packages/chromexup/default.nix { }) + (callPackage ./packages/emacs-batch-indent/default.nix { }) + (callPackage ./packages/hugo/default.nix { }) (callPackage ./packages/pdf2htmlex/default.nix { }) (callPackage ./packages/rxvt-unicode/default.nix { }) (callPackage ./packages/systemd2nix/default.nix { }) @@ -84,7 +85,6 @@ in bat bind bleachbit - caddy cava csvkit curlftpfs @@ -452,6 +452,7 @@ in pygments pylint ])) + ruff ]; }; @@ -557,6 +558,11 @@ in paths = [ guile sbcl ]; }; + HTTP = pkgs.buildEnv { + name = "http"; + paths = [ caddy apacheHttpd ]; + }; + CSS = pkgs.buildEnv { name = "css"; paths = [ diff --git a/.config/nixpkgs/packages/emacs-batch-indent/default.nix b/.config/nixpkgs/packages/emacs-batch-indent/default.nix new file mode 100644 index 0000000..92042af --- /dev/null +++ b/.config/nixpkgs/packages/emacs-batch-indent/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv, fetchgit }: + +stdenv.mkDerivation rec { + + name = "emacs-batch-indent"; + version = "145e8771b9709a82e3df82cdc06c6d9505de905d"; + url = "https://github.com/cwfoo/emacs-batch-indent"; + + src = fetchgit { + inherit url; + rev = version; + sha256 = "sha256-Qqg/ZLbfTZnH2aO7ZW2XiiVBqEvK2+LMo2Kz6HSnOCE="; + }; + + phases = [ "unpackPhase" "installPhase" ]; + + installPhase = '' + runHook preInstall + mkdir --parents $out/bin + cp emacs-batch-indent $out/bin + runHook postInstall + ''; + + meta = with lib; { + homepage = url; + license = licenses.gpl3; + platforms = platforms.linux; + description = "Indent Common Lisp, Emacs Lisp, and Scheme from the command line using Emacs."; + }; +} diff --git a/.vim/vimrc b/.vim/vimrc index 9d985ea..db24101 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -292,7 +292,7 @@ augroup AutoCommands autocmd FileType markdown autocmd! BufWritePost :only | :term ++rows=10 sh -c "cat % | vale --ext .md" autocmd FileType css autocmd! BufWritePost exe 'Notify(''prettier --write --parser css ' . expand('%') . ' 2>&1'')' | :e autocmd FileType html autocmd! BufWritePost exe 'Notify(''prettier --write --parser html ' . expand('%') . ' 2>&1'')' | :e - autocmd FileType python autocmd! BufWritePost exe 'Notify(''black ' . expand('%') . ' 2>&1 && pylint ' . expand('%') . ' 2>&1'')' | :e + autocmd FileType python autocmd! BufWritePost exe 'Notify(''ruff --no-cache ' . expand('%') . ' 2>&1 && black ' . expand('%') . ' 2>&1'')' | :e autocmd FileType nim autocmd! BufWritePost exe 'Notify(''nimpretty ' . expand('%') . ' 2>&1 && printf "Nim OK: ' . expand('%') . '"'')' | :e autocmd FileType rust autocmd! BufWritePost exe 'Notify(''rustfmt ' . expand('%') . ' 2>&1 && printf "rustfmt OK: ' . expand('%') . '"'')' | :e autocmd FileType json autocmd! BufWritePost exe 'Notify(''jsonlint -i ' . expand('%') . ' 2>&1 && printf "JSON OK: ' . expand('%') . '"'')' | :e @@ -326,21 +326,22 @@ augroup AutoCommands " File type function under cursor lookups. autocmd FileType go noremap df :exe ':term ++rows=10 go doc ' . expand('') - autocmd FileType nix noremap df :exe ':term ++rows=10 nixos-option ' . expand('') autocmd FileType elixir noremap df :exe ':term ++rows=10 sh -c "echo ''h(' . expand('') . ')'' \| iex"' " REPL commands. + autocmd FileType bash noremap cc :REPL bash -x + autocmd FileType elixir noremap cc :REPL iex autocmd FileType go noremap cc :REPL gore + autocmd FileType javascript noremap cc :REPL node autocmd FileType lua noremap cc :REPL lua - autocmd FileType php noremap cc :REPL psysh - autocmd FileType elixir noremap cc :REPL iex - autocmd FileType sh noremap cc :REPL dash -x - autocmd FileType rust noremap cc :REPL evcxr autocmd FileType nix noremap cc :REPL nix repl - autocmd FileType bash noremap cc :REPL bash -x - autocmd FileType python noremap cc :REPL python autocmd FileType perl noremap cc :REPL perl -de0 - autocmd FileType javascript noremap cc :REPL node + autocmd FileType php noremap cc :REPL psysh + autocmd FileType python noremap cc :REPL python + autocmd FileType rust noremap cc :REPL evcxr + autocmd FileType scheme noremap cc :REPL guile + autocmd FileType sh noremap cc :REPL dash -x + autocmd FileType typescript noremap cc :REPL deno autocmd FileType awk noremap cc :term ++rows=10 ++close awk -f % " Selective formatting using visual select + gq. @@ -348,9 +349,12 @@ augroup AutoCommands autocmd FileType sh set formatprg=shfmt\ - autocmd FileType typescriptreact set formatprg=deno\ fmt\ - autocmd FileType typescript set formatprg=deno\ fmt\ - + autocmd FileType python set formatprg=black\ --quiet\ - + autocmd FileType scheme set formatprg=emacs-batch-indent\ scheme + autocmd FileType css set formatprg=prettier\ --parser\ css\ --stdin-filepath\ % autocmd FileType html set formatprg=prettier\ --parser\ html\ --stdin-filepath\ % - autocmd FileType javascript set formatprg=swc\ compile\ --filename\ %\ \|\ tail\ --lines\ +2 autocmd FileType markdown set formatprg=prettier\ --parser\ markdown\ --stdin-filepath\ % + autocmd FileType javascript set formatprg=swc\ compile\ --filename\ %\ \|\ tail\ --lines\ +2 autocmd FileType ruby set formatprg=rubocop\ --autocorrect\ --stderr\ --stdin\ %\ 2>\ \/dev\/null " Set file types. -- cgit v1.2.3