You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling vim.lsp.buf.format() in ["*"] = {} (for any file type), an error is thrown about an out of bound index in get_lines.
Shell command and output (optional):
E5108: Error executing lua ...ack/packer/start/formatter.nvim/lua/formatter/format.lua:61: Index out of bounds
stack traceback:
[C]: in function 'get_lines'
...ack/packer/start/formatter.nvim/lua/formatter/format.lua:61: in function 'start_task'
...ack/packer/start/formatter.nvim/lua/formatter/format.lua:49: in function 'format'
[string ":lua"]:1: in main chunk
Which configuration?
Type (custom or builtin): custom
Filetype: * / all
Formatter: vim.lsp.buf.format()
Configuration(s) (post all the variants you tried):
require("formatter").setup({
logging=true,
log_level=vim.log.levels.WARN,
filetype= {
-- formatters are executed in order within their own tableslua= {
require("formatter.filetypes.lua").stylua,
},
bash= {
require("formatter.filetypes.sh").shfmt,
},
javascript= {
require("formatter.filetypes.javascript").eslint_d,
},
css= {
require("formatter.filetypes.css").prettierd,
},
scss= {
require("formatter.filetypes.css").prettierd,
},
html= {
require("formatter.filetypes.html").prettierd,
},
json= {
require("formatter.filetypes.json").prettierd,
},
-- for any filetype
["*"] = {
require("formatter.filetypes.any").remove_trailing_whitespace,
-- formatting logic: See if formatter.nvim can do it, then check if lsp can do it,-- then notify if neither can do it. The keybind is then universally ":Format", as this-- logic is run when formatter.nvim is run.function()
localformatters=require("formatter.util").get_available_formatters_for_ft(vim.bo.filetype)
if#formatters>0thenprint("formatted with formatter.nvim")
returnendlocallsp_clients=vim.lsp.buf_get_clients()
-- check if there are any LSP formattersfor_, clientinpairs(lsp_clients) doifclient.server_capabilities.document_formattingthenvim.lsp.buf.format()
print("formatted with lsp")
returnendendprint("no formatters found from formatter.nvim OR lsp")
end,
},
},
})
I've also tried by only calling format(), same error:
That when running vim.lsp.buf.format() via formatter.nvim that the text is formatted without error.
+ Note: I ran formatter.nvim when editing a go file (i.e. not a filetype I'm targeting).
I am able to call vim.lsp.buf.format() manually in the file and format without error.
If I simply undo the formatting and try with formatter.nvim (via :Format or :FormatWrite) I get the above error.
Actual behaviour
The error is output, and when cleared with a keypress (confirming the error), the text formats correctly.
When calling
vim.lsp.buf.format()
in["*"] = {}
(for any file type), an error is thrown about an out of bound index inget_lines
.Shell command and output (optional):
Which configuration?
Type (custom or builtin): custom
Filetype: * / all
Formatter:
vim.lsp.buf.format()
Configuration(s) (post all the variants you tried):
I've also tried by only calling format(), same error:
Expected behavior
That when running
vim.lsp.buf.format()
via formatter.nvim that the text is formatted without error.+ Note: I ran formatter.nvim when editing a go file (i.e. not a filetype I'm targeting).
I am able to call
vim.lsp.buf.format()
manually in the file and format without error.If I simply undo the formatting and try with formatter.nvim (via
:Format
or:FormatWrite
) I get the above error.Actual behaviour
The error is output, and when cleared with a keypress (confirming the error), the text formats correctly.
Additional context
This has been commented on before here: #260
The text was updated successfully, but these errors were encountered: