-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nvim): use conform to format Lua files
This is replacing using formatprg to run the same program (stylua), this has extra benefits. Conform has the ability to run automatically on save, but this is currently using `formatexpr` to run on demand using `gq`.
- Loading branch information
Showing
4 changed files
with
14 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,5 @@ | ||
-- Tabs should have 4 space width. | ||
vim.opt_local.tabstop = 4 | ||
|
||
-- Use stylua as formatter if it is available. | ||
if vim.fn.executable("stylua") == 1 then | ||
vim.opt_local.formatprg = "stylua --stdin-filepath % --search-parent-directories -" | ||
end | ||
|
||
-- Use luacheck as compiler for sh files. | ||
vim.cmd([[compiler luacheck]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
local options = { | ||
formatters_by_ft = { | ||
lua = { "stylua" }, | ||
}, | ||
} | ||
|
||
require("conform").setup(options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters