Install with your favorite plugin manager.
itchyny (https://github.com/itchyny)
This software is released under the MIT License, see LICENSE.
If the plugin does not work for some syntax, feel free to report to the issue tracker!
License: MIT License
Install with your favorite plugin manager.
itchyny (https://github.com/itchyny)
This software is released under the MIT License, see LICENSE.
When I wrote a example of Spock, I expect indent like this:
main = runSpock 3000 $ spockT id $ do
get("echo" <//> var) $ \something ->
text $ T.concat ["Echo: ", something]
But vim =
works below:
main = runSpock 3000 $ spockT id $ do
get("echo" <//> var) $ \something ->
text $ T.concat ["Echo: ", something]
While I encountered this behavior in a Spock example,
I believe many anonymous functions tend to have line break inside itself.
こんにちは。issueを投げることが初めてなので勝手がわからないのですが、どうかご容赦ください。
Haskellで以下のようなlet、whereを使うコードを書いたところ、indentが思った位置に行きませんでした。
cylinder :: Double -> Double -> Double
cylinder r h =
let sideArea = 2 * pi * r * h
topArea = pi * r ^ 2
in sideArea + 2 * topArea
topAreaがsideAreaと並ぶものだと思っていたのですが、行頭から1タブのところに来ます。
describeList' :: [a] -> String
describeList' ls = "The list is " ++ what ls
where what [] = "empty."
what [x] = "a singleton list."
what xs = "a longer list."
こちらもwhatが並行になりません。行頭から1タブのところに配置されます。
これは仕様通りでしょうか?
f x = 10
where g x y
| x < y = y
| otherwise = x
Hello! I'm new to haskell. Great plugin, but I have an issue with indentation. I have this code:
fizzbuzz = map fizzbuzzify [1..]
where fizzbuzzify n = if words == "" then show n else words
where words = "" ++
(if mod n 3 == 0 then "Fizz" else "") ++
(if mod n 5 == 0 then "Buzz" else "")
(which I indented myself) but when I type it into vim while using the plugin I get this:
fizzbuzz = map fizzbuzzify [1..]
where fizzbuzzify n = if words == "" then show n else words
where words = "" ++
(if mod n 3 == 0 then "Fizz" else "") ++
(if mod n 5 == 0 then "Buzz" else "")
The indentation of the code in parens is not indented far enough and haskell doesn't compile. I tried with both 4-space tabs and 2-space tabs. Help?
Edit: The indentation is initially correct when I press enter, but it messes itself up when I then type a (
instance X Z
instance Y Z where
f x = x
First of all, great thanks for the plugin.
In the following snippet, the Nothing
case should be aligning against Just n
. It is wrongfully taken as a further pattern for the inner case expression when indenting:
case_ :: Maybe Int -> Int
case_ x = case x of Just n -> case n of 1 -> 1
_ -> (-1)
Nothing -> 0
-- after indent --------------------------------
case3 :: Maybe Int -> Int
case3 x = case x of Just n -> case n of 1 -> 1
_ -> (-1)
Nothing -> 0
Which is not desired. Similarly:
class A a where
aa :: Int
other_function :: () -> ()
other_function = undefined
-- after indent --------------------------------
class A a where
aa :: Int
other_function :: () -> ()
other_function = undefined
The list goes on.
Hi,
I met an issue with the indentation in a code with TypeFamilies
. This code from the haskell wiki is de-indented on the data
line.
Expected (with 4 spaces):
class GMapKey k where
data Gmap k :: * -> *
empty :: Gmap k v
Currently:
class GMapKey k where
data Gmap k :: * -> *
empty :: Gmap k v
Edit: similarly in the instance declaration:
instance GMapKey Int where
data GMap Int v = GMapInt (Data.IntMap.IntMap v)
f = g
$ h
$ x
Hello. Thank you for this very useful plugin!
I, however, encountered the problem that it defaults to inserting 8 tabs every time an indentation is expected (even though my tabstop
is set to 4). Is there a way I can configure this behavior?
Hi, thanks for your plugins!
I encountered issues regarding indentation for newlines after let
. Codes like this:
-- input 0
f = let
foo = 3
in
print foo
or this:
-- input 1
f = let foo = bar
baz = poi
in putStrLn "mof"
are broken after gg=G
.
-- result 0
f = let
foo = 3
in
print foo
-- result 1
f = let foo = bar
baz = poi
in putStrLn "mof"
I have no fixed opinion about the desired result for these examples.
data X = X {
x :: I,
y :: J
}
When writing a closed type family, on pressing enter after writing where
, the indent is relative to the position of the where
. However, it should be relative to the beginning of the line.
type family Test where
A B
A
: Where the cursor should be
B
: Where the cursor actually ends up
Hello,
I encountered bugs about indention on GADT syntax when I was writing codes like this,
{-# LANGUAGE GADTs #-}
data Expr a where
I :: Int -> Expr Int
The correct indention should indent two spaces just as the above code, but your plugin will give this,
{-# LANGUAGE GADTs #-}
data Expr a where
I :: Int -> Expr Int
Since I am not familiar with vimrc's syntax, I don't have any ideas on how to fix this :(
But I think it would be easy to fix, because I have noticed that
instance Monad Test where
return = undefined
gives the correct indention :)
Hi, I typed the following sample code in, letting the autoindenter decide what to do on each line:
main = do
let n = 1
if n > 0
then do
putStrLn "hello"
else putStrLn "goodbye"
I'm not sure if the way I've ended lines on do
is good style, but breaking to a new line and writing do putStrLn "hello"
produces strange results too. The issue here is that the else
block is aligned too far right. Unfortunately, using <<
to unindent that line produces this result:
if n > 0
then do
putStrLn "hello"
else putStrLn "goodbye"
The else
was moved just one space left. I think the else
should be matched to the lexically-enclosing if
(since you can't have an if
expression without an else
in Haskell), and set to the same level as the then
. Even without that part though, I'm a bit confused by the behaviour of <<
here.
f = do
let x = 1
let y = 2
return (x, y)
f = do
let x = 1
in let y = x
in return (x, y)
if you want to write a function under it's definition the only way to get it indented right is to press enter right after the =
sign. if there is a space after it like so =
and you press enter to go down to the next line then indentation will not be triggered.
This happens quite often when you want to redefine a 1 line function over multiple lines like this:
myFunction x = undefined
here I would do $bC<cr>
and the resulting indentation would be this because the cursor wasn't right after =
when pressing enter.
myFunction x =
someCode
thanks for great vim plugin!!
im new to haskell, so not sure if this is some problem with me or plugin.
before
https://gist.github.com/naofumi-fujii/88e06f460c6e7b4c4cd87c968ab8e9af
after
https://gist.github.com/naofumi-fujii/fba2c8fc2f56a860bd1407b0a26b0216
when the let expression only binds 1 thing it's ok because the in
will be auto indented
let square x = x*x
in square 3
however if you want to bind more stuff then indentation isn't triggered
let square x = x*x
x = 3
in square x
You have to reindent it with =ip
and then it will produce the expected output
let square x = x*x
x = 3
in square x
Code like the following fails to indent (or indents to the level of f
):
f (x,y) = [x,
y]
or:
f [x,y] = [x,
y]
I think the (x,y)
or [x,y]
in the argument list is confusing the parser / regex.
Does vim-haskell-indent require extra installation when using Plug? It doesn't seem to be compatible.
The relevant line of my vrc is
Plug 'itchyny/vim-haskell-indent' " Haskell Indent
Thanks
like this:
main = do
string <- getLine
print string
doing gg=G
will make it indented like this:
main = do
string <- getLine
print string
Hi!
I tried your plugin and everything was working pretty fine until I started lurking on the Yesod framework.
There is a problem with the very first example program given here.
The code indentation breaks after the line instance Yesod HelloWorld
Is there any chance to fix that?
Thanks in advance!
I realize this might not be good code style, but putting where
or do
blocks and their contents on a single line often makes the next line incorrectly indented.
instance Show A where show A = "A"
instance Show B where show B = "B"
run (Add a) = do modify (+a); get
run (Multiply a) = do modify (*a); get
Differentiating those cases from those where you do want the next line to be indented might be difficult though.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.