-
Notifications
You must be signed in to change notification settings - Fork 6
/
stylua-nvim.txt
93 lines (70 loc) · 3.36 KB
/
stylua-nvim.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
*stylua-nvim.txt* stylua-nvim
A minimal wrapper around https://github.com/JohnnyMorganz/StyLua to provide a
way to format Lua in an opinionated way while in Nvim, because no one wants to
spend time discussing how you should format.
STYLUA-NVIM REFERENCE MANUAL
CONTENTS *stylua-nvim*
1. Prerequisites......... |stylua-nvim-prerequisites|
2. Getting Started....... |stylua-nvim-getting-started|
3. Lua API............... |stylua-nvim-lua-api|
4. Example Usage......... |stylua-nvim-example-usage|
================================================================================
PREREQUISITES *stylua-nvim-prerequisites*
- Nvim v0.5.x
- Make sure to have StyLua installed. You can find instructions here:
https://github.com/JohnnyMorganz/StyLua
================================================================================
GETTING STARTED *stylua-nvim-getting-started*
Install via your favorite package manager.
>
use({"ckipp01/stylua-nvim"})
<
This plugin does not require that setup be called, however it is possible to
provide additional configuration using the setup function.
>
use({"ckipp01/stylua-nvim"},
config = function()
require("stylua-nvim").setup{config_file = "stylua.toml"}
end)
<
Available setup options:
config_file Specifies a configuration file to use for the StylLua
linter. This can be an absolute or relative path. The
default value is nothing, which means the linter will
search for a stylua.toml file using the
`--search-parent-directories` option of the linter.
error_display_strategy The mechanism to display errors encountered during
linting. Allowed values are 'loclist' or 'none'. Default
value is 'loclist'.
================================================================================
LUA API *stylua-nvim-lua-api*
*format_file(config)*
format_file(config) Use to format the current buffer. If any issues are
found, they will be opened in your loclist.
Takes an optional configuration argument
{
error_display_strategy = <error_display_string>
}
<error_display_string> options currently are:
* "loclist": display errors in a location list
* "none": do not display stylua errors
================================================================================
Example Usage *stylua-nvim-example-usage*
Via a mapping: >
local opts = { noremap=true, silent=true }
buf_set_keymap("n", "<leader>f", [[<cmd>lua require("stylua-nvim").format_file()<CR>]], opts)
<
Usage via nvim-lspconfig and sumneko_lua to be able to use `:Format`: >
local lsp_config = require("lspconfig")
lsp_config.sumneko_lua.setup({
commands = {
Format = {
function()
require("stylua-nvim").format_file()
end,
},
},
...
})
<
vim:tw=80:ts=2:ft=help: