diff options
| author | Vzaa <Vzaa@users.noreply.github.com> | 2022-08-24 11:17:50 +0300 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2022-09-13 15:30:23 -0400 |
| commit | d30a10849b0963022f94f0ad9c3fcea74e43008b (patch) | |
| tree | 59320006f7c45b80936d33ae37a631bc7a182aa0 /nvim | |
| parent | 3304cad64b8b7a9f60c1e21c02d509d0e81cb1fc (diff) | |
| download | dots-d30a10849b0963022f94f0ad9c3fcea74e43008b.tar.gz | |
Don't pass args to vim.lsp.buf.format/formatting
Args passed by nvim_buf_create_user_command to the callback creates
errors with rust-analyzer on nvim 0.7.x and vim.lsp.buf.formatting.
Diffstat (limited to 'nvim')
| -rw-r--r-- | nvim/init.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nvim/init.lua b/nvim/init.lua index 20f35d7..47a0abc 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -289,7 +289,13 @@ local on_attach = function(_, bufnr) end, '[W]orkspace [L]ist Folders') -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', vim.lsp.buf.format or vim.lsp.buf.formatting, { desc = 'Format current buffer with LSP' }) + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + if vim.lsp.buf.format then + vim.lsp.buf.format() + elseif vim.lsp.buf.formatting then + vim.lsp.buf.formatting() + end + end, { desc = 'Format current buffer with LSP' }) end -- nvim-cmp supports additional completion capabilities |