Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 2.05 KB

README.md

File metadata and controls

74 lines (47 loc) · 2.05 KB

Last Modified: 2023-07-03 00:00:00

vim-lua-format.nvim is forked from vim-lua-format, and rewrited wth lua.

Add default lua-format config file:".lua_format.default"(when not found ".lua-format" then using this default config file).

Lua vim formatter supported by LuaFormatter(lua-format).

Install

Use lazy.nvim, add this to "plugin.lua"

{
    "pchaos/vim-lua-formatter.nvim",
    branch="main",
    ft={ "lua"}
},

And it's done!

Then press <C-K> or simply save some *.lua file to format the Lua code automatically.

NOTE if you need to use the LuaFormat() function directly from command mode, you should call it explicitly as :lua LuaFormat()

Features

Reformats your Lua source code with default config file : ".lua-format.default".

Extension Settings

The .lua-format file must be in the source or parent directory. If there is no configuration file the default settings are used.

Known Issues

  1. You may have an error that claims unknown -i or -si options. This is happening because some versions of lua-formatter uses different flags.

So if you get any error about unknown flag, just change it to the correct flag in flags string variable at lua_format_format() function.

  1. No line breaks after closing block comment In files with block comments, something like this:
--[[
Bigger comment
--]]

local var

becomes this after format with lua-format default settings.

--[[
Bigger comment
--]] local var

This was seen with the version included in current formatter:lua-format (version 1.3.6)

A workaround for this issue is ending a multiline comment with --]] --

--[[
Bigger comment
--]] --

local var