venantius / vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
152 stars 22 forks source link

Formatting truncates output #43

Open imamatory opened 5 years ago

imamatory commented 5 years ago

When call either Cljfmt or CljfmtRange on the whole buffer it truncates text. Debugging the plugin with echo ended with wrong capturing fireplace#session_eval output The function called with correct buffer content returns truncated result or redir behaves unexpectedly here: https://github.com/venantius/vim-cljfmt/blob/f4bbc04967202a2b94a0ebbb3485991489b9dcd4/plugin/cljfmt.vim#L61-L73 Example of work: Source

(ns battle-asserts.issues.array-transpose
  (:require [clojure.test.check.generators :as gen]))

(def level :easy)

(def description "Implement the matrix transposition function.
                  Matrices are presented as arrays of arrays, where internal arrays are rows of the matrix.
                  There are different ways to transpose a matrix:
                  1) reflect the array over its main diagonal (which runs from top-left to bottom-right);
                  2) write the rows of the original matrix as columns of the new one;
                 3) write the columns of the original matrix as rows of the new one.")

(defn signature []
  {:input [{:argument-name "arr1" :type {:name "array" :nested "integer"}}
           {:argument-name "arr2" :type {:name "array" :nested "integer"}}]
   :output {:type {:name "array" :nested {:name "array" :nested "integer"}}}})

(defn arguments-generator []
  (gen/tuple (gen/bind (gen/choose 2 5)
                       #(gen/vector (gen/vector gen/int %)))))

(def test-data
  [{:expected [[1 10] [2 20] [3 30]]
    :arguments [[[1 2 3] [10 20 30]]]}
   {:expected [[1 3 5] [2 4 6]]
    :arguments [[[1 2] [3 4] [5 6]]]}
   {:expected []
    :arguments [[]]}])

(defn solution [vectors]
  (if (not-empty vectors)
    (apply mapv vector vectors)
    []))

After fixing

(ns battle-asserts.issues.array-transpose
  (:require [clojure.test.check.generators :as gen]))

(def level :easy)

(def description "Implement the matrix transposition function.
                   Matrices are presented as arrays of arrays, where internal arrays are rows of the matrix.
                   There are different ways to transpose a matrix:
                   1) reflect the array over its main diagonal (which runs from top-left to bottom-right);
                   2) write the rows of the original matrix as columns of the new one;
                  3) write the columns of the original matrix as rows of the new one.")

(defn signature []
  {:input [{:argument-name "arr1" :type {:name "array" :nested "integer"}}
           {:argument-name "arr2" :type {:name "array" :nested "integer"}}]
   :output {:type {:name "array" :nested {:name "array" :nested "integer"}}}})

(defn arguments-generator []
  (gen/tuple (gen/bind (gen/choose 2 5)
                       #(gen/vector (gen/vector gen/int %)))))

(de

My ~/.lein/profiles.clj

{:user {:plugins [[cider/cider-nrepl "0.21.1"]
                  [jonase/eastwood "0.3.5"]
                  [lein-cljfmt "0.6.4"]]
        :dependenies [[cljfmt "0.6.4"]
                      [jonase/kibit "0.1.6" :exclusions [org.clojure/clojure]]]
        :repl-options {:init (require 'cljfmt.core)}
        }}

P.S. I have set up clojure environment first time and probably missed some points

venantius commented 5 years ago

You have a typo in your :dependencies key in your .lein/profiles.clj

imamatory commented 5 years ago

Thanks. Now line with repl-options don't crash it down. But the main problem still here.

Also there is not :CljFmtRange command found in my editor however i used it earlier. If i use Plug 'venantius/vim-cljfmt', { 'for': 'clojure' } CljFmtRange appears in the first opened buffer in current vim session however if i try to open another buffer it hangs until i press ctrl-c and after that there is no :CljFmtRange in menu.

if i use Plug 'venantius/vim-cljfmt' :CljFmtRange don't appears at all.

My vimrc if it can help https://github.com/imamatory/dotfiles/blob/master/files/vimrc