File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,10 +12,23 @@ To find out more:
1212https://github.com/wesleimp/stylua.nvim
1313
1414
15- stylua.format({bufnr } ) *stylua.format*
16- Format your Lua code. If {bufnr } is not set, the current buffer will be
15+ stylua.format({opts } ) *stylua.format*
16+ Format your Lua code. If {opts } is not set, some defaults will be
1717 used to format >
1818
19+ Parameters: ~
20+ {opts} (table) options to pass to the formatter
21+
22+ Options: ~
23+ {bufnr} (number) specify the buffer number where
24+ treesitter should run. (default:
25+ current buffer)
26+
27+ {config_path} (string) specify the config file to use.
28+ (default: .stylua.toml or
29+ stylua.toml defined in the
30+ project)
31+
1932 :lua require("stylua").format()
2033<
2134vim:tw=78:ts=8:ft=help:norl:
Original file line number Diff line number Diff line change @@ -38,10 +38,17 @@ local function find_stylua(path)
3838 return M ._config [path ]
3939end
4040
41- function M .format (bufnr )
42- bufnr = bufnr or vim .api .nvim_get_current_buf ()
43- local filepath = Path :new (vim .api .nvim_buf_get_name (bufnr )):absolute ()
44- local stylua_toml = find_stylua (filepath )
41+ function M .format (opts )
42+ opts = opts or {}
43+ local bufnr = opts .bufnr or vim .api .nvim_get_current_buf ()
44+
45+ local stylua_toml
46+ if opts .config_path then
47+ stylua_toml = Path :new (opts .config_path ):absolute ()
48+ else
49+ local filepath = Path :new (vim .api .nvim_buf_get_name (bufnr )):absolute ()
50+ stylua_toml = find_stylua (filepath )
51+ end
4552
4653 local args = {}
4754
You can’t perform that action at this time.
0 commit comments