Skip to content

Fix multi argument indent when using noexpandtab; make it optional#4

Open
idbrii wants to merge 2 commits intoraymond-w-ko:masterfrom
idbrii:fix-multiline-align
Open

Fix multi argument indent when using noexpandtab; make it optional#4
idbrii wants to merge 2 commits intoraymond-w-ko:masterfrom
idbrii:fix-multiline-align

Conversation

@idbrii
Copy link

@idbrii idbrii commented Mar 13, 2022

Cleaned up version of suokko's fix from #2 to more closely match existing code style and naming.

We must \t as &shiftwidth instead of a single char. Can't use
GetStringIndent because it stops when it hits non whitespace and making
it support both cases is awkward.

With noet sw=8 ts=8 old behaviour:

f = function(a,
	     b)
	print(a)
	g = function(a,
	      b)
	end
end

New behaviour fixes indent for g:

f = function(a,
	     b)
	print(a)
	g = function(a,
		     b)
	end
end

Also add g:lua_indent_align_params. let g:lua_indent_align_params = 0 for single indent for function params:

  f = function(a,
      b)
      print(a)
      g = function(a,
          b)
      end
  end
  g = function(a,
      b)
  end

  create(10,
      20,
      30,
      get(
          1,
          2),
      val())

Trying to evaluate indentation in this plugin vs tbastos/vim-lua, so I thought I'd contribute some changes I made along the way. In the end, tbastos's version seems like it'll better support chained function calls so that may be a deciding factor for me.

idbrii added 2 commits March 12, 2022 17:19
Cleaned up version of suokko's fix from:
raymond-w-ko#2
(Renaming and making the new func more like GetStringIndent.)

We must \t as &shiftwidth instead of a single char. Can't use
GetStringIndent because it stops when it hits non whitespace and making
it support both cases is awkward.

With `noet sw=8 ts=8` old behaviour:

f = function(a,
	     b)
	print(a)
	g = function(a,
	      b)
	end
end

New behaviour fixes indent for g:

f = function(a,
	     b)
	print(a)
	g = function(a,
		     b)
	end
end
let g:lua_indent_align_params = 1 for aligning function params:

  f = function(a,
               b)
      print(a)
      g = function(a,
                   b)
      end
  end
  g = function(a,
               b)
  end

  create(10,
         20,
         30,
         get(
             1,
             2),
         val())

let g:lua_indent_align_params = 0 for single indent for function params:

  f = function(a,
      b)
      print(a)
      g = function(a,
          b)
      end
  end
  g = function(a,
      b)
  end

  create(10,
      20,
      30,
      get(
          1,
          2),
      val())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant