cfm formatter lsp

This commit is contained in:
Barak Michener 2021-08-17 11:13:24 -07:00
parent deecd96cc9
commit 2a36ef6c0b
2 changed files with 20 additions and 0 deletions

View file

@ -9,6 +9,22 @@ end
nvim_lsp.rust_analyzer.setup({ on_attach=on_attach })
nvim_lsp.gopls.setup({ on_attach=on_attach })
nvim_lsp.pyright.setup({ on_attach=on_attach })
nvim_lsp.clangd.setup({ on_attach=on_attach })
nvim_lsp.efm.setup {
init_options = {documentFormatting = true},
settings = {
rootMarkers = {".git/"},
languages = {
lua = {
{ formatCommand = "lua-format -i", formatStdin = true }
},
python = {
{ formatCommand = 'black --quiet -', formatStdin = true }
}
}
}
}
-- Enable diagnostics
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(

4
.vimrc
View file

@ -304,6 +304,10 @@ set updatetime=500
" Show diagnostic popup on cursor hold
autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics({show_header = false, focusable = false})
" Autoformat on save
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 1000)
autocmd BufWritePre *.py lua vim.lsp.buf.formatting_sync(nil, 1000)
" Goto previous/next diagnostic warning/error
nnoremap <silent> g[ <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
nnoremap <silent> g] <cmd>lua vim.lsp.diagnostic.goto_next()<CR>