Giter Site home page Giter Site logo

itchyny / vim-haskell-indent Goto Github PK

View Code? Open in Web Editor NEW
106.0 5.0 8.0 134 KB

If the plugin does not work for some syntax, feel free to report to the issue tracker!

License: MIT License

Haskell 49.35% Vim Script 50.65%
haskell vim vim-plugin vim-indent

vim-haskell-indent's Introduction

vim-haskell-indent CI Status

The best indent plugin for Haskell in Vim

vim-haskell-indent

vim-haskell-indent

vim-haskell-indent

Installation

Install with your favorite plugin manager.

Author

itchyny (https://github.com/itchyny)

License

This software is released under the MIT License, see LICENSE.

vim-haskell-indent's People

Contributors

aiya000 avatar itchyny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vim-haskell-indent's Issues

Installation

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

white lines in do blocks

like this:

main = do
    string <- getLine

    print string

doing gg=G will make it indented like this:

main = do
    string <- getLine

print string

multiline function indentation is finicky

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

Multiline let expressions don't auto indent

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

手元のvimでletとwhereの改行後のindentがずれてしまう

こんにちは。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タブのところに配置されます。

これは仕様通りでしょうか?

Wrong indention for newlines after `let` ?

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.

do-blocks within if then/else produce confusion indentation

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.

Indentation issue.

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!

Indentation issue

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 (

4 spaces instead of 8 indentation?

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?

Wrong indentation after single-line where and do

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.

associated data family declaration with TypeFamilies

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)

Wrong indention for GADT syntax

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 :)

Wrong indentation due to `where` in closed type family

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

Wrong indentation for line break in anonymous function?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.