Description
What
EmmyLuaCodeStyle is the built in formatter for lua-language-server: https://luals.github.io/wiki/settings/#format
It can be invoked via vim.lsp.buf.format()
and has a command line tool CodeFormat
.
Why
The stylua nvim plugin is finicky and outdated. It is a barrier to entry for devs who usually end up using style
and style-fix
, often not seeing style issues until CI, which is not run for first time contributors.
Differences
List, table and comment formatting is more readable:
local WATCHED_FILES = {
"FETCH_HEAD", -- remote ref
"HEAD", -- local ref
"HEAD.lock", -- HEAD will not always be updated e.g. revert
"config", -- user config
"index", -- staging area
}
M.HIGHLIGHT_GROUPS = {
-- Standard
{ group = "NvimTreeNormal", link = "Normal" },
{ group = "NvimTreeNormalFloat", link = "NormalFloat" },
{ group = "NvimTreeNormalFloatBorder", link = "FloatBorder" },
{ group = "NvimTreeNormalNC", link = "NvimTreeNormal" },
call_parentheses = "None"
cannot be implemented, as per stylua single table/string argument with no following call. Always using parenthesis (needs 1.5.4) results in more readable code. This only really affects require
calls.
Formatting may only be disabled via comment, not re-enabled.
space_before_closure_open_parenthesis = true
(default) looks a little more readable, however it's not really the lua standard.
How
Do this when there are no outstanding large PRs.
.editorconfig
is used with extensions. It's automatically picked up by nvim, and must be specified on the CLI.
- Add to
.editorconfig
, changes to defaults only - Move
default_on_attach
to the end, prepending---@format disable
CodeFormat format -w lua -c .editorconfig
- Remove stylua
- Update Makefile
- Commit and merge
- Update Doc