Skip to content

Instantly share code, notes, and snippets.

@ClashTheBunny
Last active September 27, 2019 22:04
Show Gist options
  • Save ClashTheBunny/cd79a700f75e43e95157f51691959cf3 to your computer and use it in GitHub Desktop.
Save ClashTheBunny/cd79a700f75e43e95157f51691959cf3 to your computer and use it in GitHub Desktop.

Revisions

  1. ClashTheBunny revised this gist Sep 27, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .vimrc_local
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    augroup YAML
    au!
    au BufReadPost *.yaml %!yaml2edn
    au BufReadPost *.yaml set ft=edn
    au BufReadPost *.yaml set ft=clojure
    au BufWritePre *.yaml %!edn2yaml
    au BufWritePost *.yaml %!yaml2edn
    au BufWritePost *.yaml set nomod
    augroup END
    augroup END
  2. ClashTheBunny revised this gist Sep 27, 2019. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,19 @@
    # So you want to edit yaml in a structured way?

    * First, install lumo and js-yaml globally and set your NODE_PATH:
    ```yarn global add lumo-cljs js-yaml```
    ```export NODE_PATH=~/.config/yarn/global/node_modules```
    ```
    yarn global add lumo-cljs js-yaml
    export NODE_PATH=~/.config/yarn/global/node_modules
    ```
    * Put `yaml2edn` and `edn2yaml` in your path.
    ```
    chmod a+x edn2yaml yaml2edn
    sudo cp yaml2edn edn2yaml /usr/local/bin/
    ```
    * Append `.vimrc_local` to your `.vimrc_local` if you have one, or copy it to your homedir:
    ```[[ -f ~/.vimrc_local ]] && cat .vimrc_local >> ~/.vimrc_local || cp .vimrc_local ~/```
    ```
    [[ -f ~/.vimrc_local ]] && cat .vimrc_local >> ~/.vimrc_local || cp .vimrc_local ~/
    ```
    `vim bla.yaml` and experience editing data in a structural way. No t-square required.
  3. ClashTheBunny revised this gist Sep 27, 2019. 1 changed file with 9 additions and 8 deletions.
    17 changes: 9 additions & 8 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    # So you want to edit yaml in a structured way?

    * First, install lumo and js-yaml globally and set your NODE_PATH:
    `yarn global add lumo-cljs js-yaml`
    `export NODE_PATH=~/.config/yarn/global/node_modules`
    ```yarn global add lumo-cljs js-yaml```
    ```export NODE_PATH=~/.config/yarn/global/node_modules```

    * Put `yaml2edn` and `edn2yaml` in your path.
    ```
    sudo cp yaml2edn edn2yaml /usr/local/bin/
    ```
    * Append `.vimrc_local` to your `.vimrc_local` if you have one, or move it to your homedir:
    `[[ -f ~/.vimrc_local ]] && cat .vimrc_local >> ~/.vimrc_local || cp .vimrc_local ~/`
    ```
    chmod a+x edn2yaml yaml2edn
    sudo cp yaml2edn edn2yaml /usr/local/bin/
    ```
    * Append `.vimrc_local` to your `.vimrc_local` if you have one, or copy it to your homedir:
    ```[[ -f ~/.vimrc_local ]] && cat .vimrc_local >> ~/.vimrc_local || cp .vimrc_local ~/```
    `vim bla.yaml` and experience editing data in a structural way. No t-square required.
    `vim bla.yaml` and experience editing data in a structural way. No t-square required.
  4. ClashTheBunny created this gist Sep 27, 2019.
    8 changes: 8 additions & 0 deletions .vimrc_local
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    augroup YAML
    au!
    au BufReadPost *.yaml %!yaml2edn
    au BufReadPost *.yaml set ft=edn
    au BufWritePre *.yaml %!edn2yaml
    au BufWritePost *.yaml %!yaml2edn
    au BufWritePost *.yaml set nomod
    augroup END
    21 changes: 21 additions & 0 deletions LICENCE
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    MIT License

    Copyright (c) 2019 Randall Mason

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
    14 changes: 14 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # So you want to edit yaml in a structured way?

    * First, install lumo and js-yaml globally and set your NODE_PATH:
    `yarn global add lumo-cljs js-yaml`
    `export NODE_PATH=~/.config/yarn/global/node_modules`

    * Put `yaml2edn` and `edn2yaml` in your path.
    ```
    sudo cp yaml2edn edn2yaml /usr/local/bin/
    ```
    * Append `.vimrc_local` to your `.vimrc_local` if you have one, or move it to your homedir:
    `[[ -f ~/.vimrc_local ]] && cat .vimrc_local >> ~/.vimrc_local || cp .vimrc_local ~/`

    `vim bla.yaml` and experience editing data in a structural way. No t-square required.
    13 changes: 13 additions & 0 deletions edn2yaml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/usr/bin/env lumo
    (ns edn2yaml.core
    (:require
    [cljs.pprint :refer [pprint]]
    [cljs.reader :refer [read-string]]))

    (def yaml (js/require "js-yaml"))
    (js/require "process")

    (.setEncoding js/process.stdin "utf8")
    (.on js/process.stdin "data"
    (fn [data]
    (println (.safeDump yaml (clj->js (read-string data))))))
    12 changes: 12 additions & 0 deletions yaml2edn
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/usr/bin/env lumo
    (ns yaml2edn.core
    (:require
    [cljs.pprint :refer [pprint]]))

    (def yaml (js/require "js-yaml"))
    (js/require "process")

    (.setEncoding js/process.stdin "utf8")
    (.on js/process.stdin "data"
    (fn [data]
    (pprint (js->clj (.safeLoad yaml data)))))