Added format and auto format support

This commit is contained in:
Wil Simpson 2023-02-28 14:09:49 -05:00
parent 555d200655
commit ca533432a6
1 changed files with 10 additions and 8 deletions

View File

@ -35,7 +35,6 @@ I hope you enjoy your Neovim journey,
P.S. You can delete this when you're done too. It's your config now :)
--]]
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
@ -406,6 +405,8 @@ local on_attach = function(_, bufnr)
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
nmap('<leader>f', function() vim.lsp.buf.format { async = true } end, 'Auto [F]ormat')
end
-- Enable the following language servers
@ -433,7 +434,6 @@ local servers = {
marksman = {},
volar = {},
yamlls = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
@ -514,5 +514,7 @@ cmp.setup {
},
}
vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]]
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et