summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 20f35d7..47a0abc 100644
--- a/init.lua
+++ b/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